Advertisement
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('Let\'s do some math with just functions!\n')
- 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\n' % (age,height,weight,iq))
- print('~' * 80)
- #a puzzle for extra credit
- print('Here is a puzzle\n')
- what = add(age,subtract(height,multiply(weight,divide(iq,2))))
- print('That becomes: ', what, 'Can you do it by hand?')
- x = iq
- w = weight
- s = height
- f = age
- print(s-x/2*w+f)
- print((s-((x/2)*w))+f)
- print(-(((int(x) / 2) * int(w)) - int(s)) + int(f) )
- #print('(((iq/2)*weight)-height)+add')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement