## call by value from one function to another

This is the place for queries that don't fit in any of the other categories.

### call by value from one function to another

Dear List,
Thank you alot for all your help till now, as i am new to python as well new to programming, please guide me to be on right track.
Here is my problem,i have a function i named it as Math(), i perform some arithmetic operation and print its result, here is my code :

Code: Select all
`import mathdef Math(x1,y1):    a = x1+y1    b = x1-y1    c = x1*y1    d = x1/y1    while True:        e1 = raw_input("which number you want for square x or y: ")        if e1 == 'x':            e = x1**2            break        elif e1 == 'y':            e = y1**2            break        else:            e1 = raw_input("please enter the valid entry x or y :")     while True:            f1 = raw_input("which number you want for square root x or y: ")         if f1 == 'x':            f = math.sqrt(x1)            break        elif f1 == 'y':            f = math.sqrt(y1)            break        else:            f1 = raw_input("please enter the valid entry x or y :")                   print "additin is: ", a    print "subtraction is:", b     print "multiplication is:", c     print "division is: ", d    print "square is:", e    print "square root is", f         return a,b,c,d,e,f    x1 = 0x = raw_input("enter first number: ")while not (x.isdigit()):    x = raw_input("enter a valid number: ")x1 = int(x)        y1 = 0y = raw_input("enter second number: ")while not (y.isdigit()):    y = raw_input("enter a valid number: ")y1 = int(y)    Math(x1,y1)`

now i have to make another function named Manipulation(), in which i have to ask user to select any of the two output of function Math()(a,b,c,d,e,f) and then perform all the arithmetic operation again .
Problem is how to compare input entered by user in Manipulation() with output of Math().

Warm regards
Last edited by micseydel on Thu Aug 01, 2013 9:39 pm, edited 1 time in total.
Reason: Locked OP.
nytman

Posts: 4
Joined: Sat Jul 27, 2013 8:44 am

### Re: call by value from one function to another

Hi there!

* we do not name functions with Capital Letters. Those are reserved for classes. Just to avoid confusion in future.
* "Problem is how to compare input entered by user in Manipulation() with output of Math()." - That is easy. You already "return" the values from there, so you can no go on and save them on the outside as well, then compare just like before:

Code: Select all
`def mytest():  return 5mynumber = mytest():if mynumber == 5:  print "hurra!"`

Hope this helps!
Last edited by micseydel on Thu Aug 01, 2013 9:39 pm, edited 1 time in total.
Reason: Removed quote after locking OP.
Due to the reasons discussed here we are moving to python-forum.net on October 1, 2016.

This forum will be closed. Please create an account at the new site to continue discussion.

IRC://irc.freenode.net/python-forum
Kebap

Posts: 689
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe