473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 2263
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

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

Similar topics

2
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
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
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
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
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
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
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
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
by: dnyanu | last post by:
how to pass php value from one div to another div within same page
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.