469,307 Members | 2,172 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

Calling a function from another function within the same class

Expand|Select|Wrap|Line Numbers
  1. class calculator():
  2.     def __init__(self,x=0,y=0):
  3.         self.first=x
  4.         self.second=y
  5.         #calculator.param=+theta
  6.  
  7.     def scaleparam(self,theta):
  8.         self.theta=theta
  9.         return self.theta
  10.  
  11.     def addition(self,theta):
  12.         self.addition1=(self.first+self.second)*self.scaleparam(theta)
  13.         return self.addition1
  14.  
  15.  
  16.  
  17. check1=calculator(3,4)  
  18.  
  19. check1.scaleparam(10)
  20.  
  21. print "the addition1 is "+str(check1.addition())
## Got error TypeError: addition() takes exactly 2 arguments (1 given)##
May 15 '15 #1
1 1855
bvdet
2,851 Expert Mod 2GB
You need to define identifier theta and pass theta to the function call as in:
Expand|Select|Wrap|Line Numbers
  1. theta = 1
  2. print "the addition1 is "+str(check1.addition(theta))
May 15 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by kingofkolt | last post: by
1 post views Thread by Itchy | last post: by
2 posts views Thread by Bloke Smith | last post: by
2 posts views Thread by Emil | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.