By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Calling a function from another function within the same class

P: 1
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
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
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.