Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ def divide(a,b):
print("I'm going use the calculator functions to multiply 5 and 6")
x = multiply(5,6)
print(x)

def square(x):
"""Return x squared."""
return x ** 2


def cube(x):
"""Return x cubed."""
return x ** 3

def square_n_times(number, n):
"""Square the number n times and return the sum."""
total = 0
current = number

for _ in range(n):
current = current ** 2
total += current

return total