Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyh23 authored Feb 21, 2017
1 parent 5d9faee commit acb8ec6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ex21.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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 "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: %d, Height: %d, Weight: %d, IQ: %d" % (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?"

0 comments on commit acb8ec6

Please sign in to comment.