473,503 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a function from another function within the same class

1 New Member
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 2274
bvdet
2,851 Recognized Expert Moderator Specialist
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

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

Similar topics

2
2045
by: kingofkolt | last post by:
hi all, just wondering what the syntax is for calling a method of a class from another method of that same class? for example... class Test { var $test="foo"; function printTest() {
1
3494
by: Itchy | last post by:
Hi! I just don't understand why my compiler complains about this line in my program (see below). Maybe you can help me? You can skip all the overloaded operators. I've marked the problem...
2
6308
by: Bloke Smith | last post by:
I have written a class (and it works!). Now I want to tidy the code a bit by separating some subroutines and I get a "Fatal error: Call to undefined function:" e.g. class Fred{ function...
6
10616
by: Ajit Goel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and...
2
1391
by: Emil | last post by:
Is it posiible to create callback for a function, that is automatically called before that function returns? I need it for tracing/profiling purposes. eg.: var execTime = null; var startTime...
1
4768
by: jman | last post by:
i've got an object and i'd like to recursively call a function within the class definition. (i've simplified the code ) function myclass() { this.loop = function(index) { // ..work
7
163
by: abhash | last post by:
I am bit puzzled at the following piece of code I tried: ---------------------------------------------------------------------------------- #include <iostream> using namespace std; class Test...
4
44139
by: Aaron Dingo | last post by:
Hi there, could you help me spot my error - I'm sure it's a simple one. I'm just trying to understand classes in Python a little better (working through Learn Python The Hard Way). Basically I...
1
6898
by: dnyanu | last post by:
how to pass php value from one div to another div within same page
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.