Skip to content

Commit ed0e3f4

Browse files
Merge pull request #2 from code4policy/calculator
Calculator
2 parents 5d19ea5 + 9d5aec4 commit ed0e3f4

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

674 Bytes
Binary file not shown.
14.9 KB
Binary file not shown.

calculator.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
def multiply(a,b):
1+
def multiply(a, b):
22
return a * b
33

4-
def add(a,b):
5-
return a+b
4+
def add(a, b):
5+
return a + b
66

7-
def subtract(a,b):
8-
return a-b
7+
def subtract(a, b):
8+
return a - b
99

10-
def divide(a,b):
11-
return a/b
10+
def divide(a, b):
11+
return a / b
1212

13-
print("I'm going use the calculator functions to multiply 5 and 6")
14-
x = multiply(5,6)
15-
print(x)
13+
def square(a):
14+
return a * a
15+
16+
def cube(a):
17+
return a ** 3
18+
19+
def square_n_times(number, n):
20+
result = number
21+
total = 0
22+
for _ in range(n):
23+
result = square(result)
24+
total += result
25+
return total
26+
27+
28+
if __name__ == "__main__":
29+
print("I'm going use the calculator functions to multiply 5 and 6")
30+
x = multiply(5, 6)
31+
print(x)

0 commit comments

Comments
 (0)