-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex21.py
More file actions
43 lines (27 loc) · 1.02 KB
/
Copy pathex21.py
File metadata and controls
43 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Exercise 21, Learning Python the Hard Way"""
def add(aay, bee):
"""Print the sum of aay and bee"""
print "ADDING %d + %d" % (aay, bee)
return aay + bee
def subtract(aay, bee):
"""Print the result of the sutraction of aay from bee"""
print "SUBTRACTING %d - %d" % (aay, bee)
return aay - bee
def multiply(aay, bee):
"""Print the result of the multiplication of aay and bee"""
print "MULTIPLYING %d * %d" % (aay, bee)
return aay * bee
def divide(aay, bee):
"""Print the result of the division of aay by bee"""
print "DIVIDING %d / %d" % (aay, bee)
return aay / bee
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?"