Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add(a, b):
- print "adding %d + %d" % (a, b)
- return a + b
- def subtract(a, b):
- print "subtracting %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 "lets do some math with just functions"
- age = add(20, 4)
- height = subtract(73, 4)
- weight = multiply(65, 2)
- iq = divide(280, 2)
- print "age: %d, height: %d, weight: %d, iq: %d" % (age, height, weight, iq)
- #a puzzle for the extra creditm, type it in anyway.
- print "heres a puzzle"
- what = add(age, subtract(height, multiply(weight, divide(iq, 2))))
- print "that becomes: ", what, "can you do it by hand?"
Advertisement
Add Comment
Please, Sign In to add comment