Q:

Python go to def

Hi there
First of all just let me say that I'm new in Python and this is for a school work so this should be done without advanced programing and global functions. Using Python 2.6.6 and WingIDE 101
I need a program to present the user with a menu. The user must pick an option and accordingly to is pick the program does what the user wants.
For example, in the code bellow (its not the actual code), if the user picks 1 it goes to the sum() function.
def menu():
    print "What do you want? "
    print " 1 for sum"
    print " 2 for subtraction"
    pick = raw_input("please insert 1 or 2 ")
    if pick == "1":
       return sum()
    if pick == "2":
       return subtraction()
    else:
        menu()
menu()

def sum():
    return 8 + 4
def subtraction():
    return 8 - 4

I what to know how do I send, after my pick, the program to execute an determined definition.
Thanks
P.S. - running this gives me this error: 
Traceback (most recent call last):
  File "/usr/lib/wingide-101-3.2/src/debug/tserver/_sandbox.py", line 12, in 
  File "/usr/lib/wingide-101-3.2/src/debug/tserver/_sandbox.py", line 7, in menu
TypeError: sum expected at least 1 arguments, got 0

A:

There are lots of things wrong with this, so we will take up one by one.
sum is a built-in function in Python. So you cannot name your function sum. You have to call yourself something else, like sum_foo. Or _sum.
Also, your code is executed from top to bottom. So if you are calling a function say X in a function like Y.
def f():
        y()
f()  
def y():
        print 'Y called'

Results in this error:
NameError: global name 'y' is not defined

Because at your program runs, it is not aware of y because the y has not been declared at that point, since the program jumps to f(). 
To fix this, you would do:
def f():
        y()    
def y():
        print 'Y called'            
f() 

Also, call the function as func_name() and not return func. And since in your sum and subtraction, you are returning the values, save them in some variable and print them, or print them directly.
def sum():
    return 8 + 4

No output
def sum():
    print 8 + 4

