pringprang

Untitled

Nov 18th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. def add(a, b):
  2. print "adding %d + %d" % (a, b)
  3. return a + b
  4.  
  5. def subtract(a, b):
  6. print "subtracting %d - %d" % (a, b)
  7. return a - b
  8.  
  9. def multiply(a, b):
  10. print "multiplying %d * %d" % (a, b)
  11. return a * b
  12.  
  13. def divide(a, b):
  14. print "dividing %d / %d" % (a, b)
  15. return a / b
  16.  
  17.  
  18. print "lets do some math with just functions"
  19.  
  20. age = add(20, 4)
  21. height = subtract(73, 4)
  22. weight = multiply(65, 2)
  23. iq = divide(280, 2)
  24.  
  25. print "age: %d, height: %d, weight: %d, iq: %d" % (age, height, weight, iq)
  26.  
  27.  
  28.  
  29. #a puzzle for the extra creditm, type it in anyway.
  30. print "heres a puzzle"
  31.  
  32. what = add(age, subtract(height, multiply(weight, divide(iq, 2))))
  33.  
  34. print "that becomes: ", what, "can you do it by hand?"
Advertisement
Add Comment
Please, Sign In to add comment