#coding utf-8
def add(a, b):
print "ADDING %d + %d" % (a,b)
#返回一个值
return a + b
def subtract(a, b):
print "SUBTRSCTING %d - %d" % (a,b)
return a - b
def multiply(a, b):
print "MULTIPLYING %d * %d" % (a,b)
return a*b
def divide(a, b):
print "DIVIDING %d / %d" % (a, b)
return a / b
print "Let's do some math with just functions!"
age = add(1, 1)
height = subtract(7, 1)
weight = multiply(2, 3)
iq = divide(8,2)
print "Age: %d, Height: %d, Weight: %d, IQ: %d" % (age, height, weight, iq)
print "Here is a puzzle."
#从右往左计算,iq/2,
what = add(age, subtract(height, multiply(weight, divide(iq,2))))
print "The becomes: ", what, "Can you do it by hand?"