Skip to content

Commit b51f138

Browse files
author
Jason Herskowitz
committed
through exercise 23
1 parent c9c84c3 commit b51f138

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Diff for: ex21.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
print "Let's do some math with just functions!"
18+
19+
age = add(30, 5)
20+
height = subtract(78, 4)
21+
weight = multiply(90, 2)
22+
iq = divide(100, 2)
23+
24+
print "Age: %d, Height: %d, Weight: %d, IQ: %d" % (age, height, weight, iq)
25+
26+
# A puzzle for extra credite
27+
print "Here is a puzzle."
28+
29+
what = add(age, subtract(height, multiply(weight, divide(iq,2))))
30+
31+
print "That becomes: ", what, "Can you do it by hand?"
32+

0 commit comments

Comments
 (0)