-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex21.py
31 lines (22 loc) · 1.12 KB
/
ex21.py
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
def add(a, b): #Define a function name add
print(f"ADDING {a} + {b}") #Print a formatted string
return(a + b) #Return a + b
def subtract(a, b): #Define a function name subtract
print(f"SUBTRACTING {a} - {b}") #Print a formatted string
return(a - b) #Return a - b
def multiply(a, b): #Define a function name multiply
print(f"Multiplying {a} * {b}") #Print a formatted string
return(a * b) #Return a * b
def divide(a, b): #Define a function name divide
print(f"Dividing {a} / {b}") #Print a formatted string
return(a / b) #Return a / b
print("Let's do some math with just functions:") #Print a string
age = add(30, 5) #Call the function
height = subtract(78, 4) #Call the function
weight = multiply(90, 2) #Call the function
iq = divide(100, 2) #Call the function
print(f"Age: {age}, Height: {height}, Weight: {weight}, IQ: {iq}") #Print a formatted string
# A puzzle for the extra credit, type it anyway.
print("Here is a puzzle.") #Print a string
what = add(age, subtract(height, multiply(weight, divide(iq,2)))) #Call the function
print("That becomes: ", what, "Can you do it by hand?") #Print a string