defadd(a,b):print("Adding {0} + {1}".format(a,b))return(a+b)defsubtract(a,b):print("SUBTRACT {0} - {1}".format(a,b))return(a-b)defmultiply(a,b):print("MULTIPLYING {0} * {1}".format(a,b))return(a*b)defdivide(a,b):print("DIVIDING {0} / {1}".format(a,b))return(a/b)print("Let's do some math with just functions")
age = add(30,5)
height = subtract(78,4)
weight = multiply(90,2)
iq = divide(100,2)# 在赋值四个变量的同时,输出四行print("Age: {0}, Height: {1}, Weight: {2}, IQ: {3}".format(age,height,weight,iq))# A puzzle for the extra credit, type it in anyway.print("Here is a puzzle.")
what = add(age, subtract(height,multiply(weight,divide(iq,2))))print("That becomes: ", what,"Can you do it by hand?")