Whenever you call a function, its body gets executed immediately.
So when you call add = ink(1, 59), the ink function's body, which contains a print statement, is executed.
Thus it prints out "Here is some math:".
Once the function's body reaches a return statement, the function's execution will end and the return statement returns a value to the place where the function was called.
So when you you do:
add = ink(1, 59)
The result is returned by ink(1, 59), then stored to add, but the result doesn't get printed yet.
You then repeat the same for other variables (fad and bad), which is why you get the printed "Here is some math:" three times before seeing any numbers.
Only later you print the actual results using:
print add
print fad
print bad
What you should do instead, is to have functions only calculate the results:
def ink(a, b):
return a + b
And usually you'd want to do the prints and inputs outside of the functions (or in main function):
add = ink(1, 59)
fad = ink(2, 9)
bad = ink(4, 2)
print "Here's some math:", add
print "Here's some math:", fad
print "Here's some math:", bad
Although repeated code is often considered bad, so you could use a for loop here (you should study more about for loops if you don't know how they work):
for result in (add, fad, bad):
print "Here's some math:", result
return a+ bto have printed the result? Or did you expect the execution of the function would be delayed untill -print add?