From b78125bd60e8b1dbc0487b7511060299bad275dd Mon Sep 17 00:00:00 2001 From: aullanisa Date: Sat, 17 Jan 2026 17:47:48 -0500 Subject: [PATCH] Added squaring, cubing, and square n times functions --- calculator.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/calculator.py b/calculator.py index 60a7932..1d3a8be 100644 --- a/calculator.py +++ b/calculator.py @@ -1,15 +1,31 @@ -def multiply(a,b): - return a * b - def add(a,b): return a+b def subtract(a,b): return a-b +def multiply(a,b): + return a * b + def divide(a,b): return a/b +def square(a): + return a*a + +def cube(a): + return a*a*a + +def square_n_times(number, n): + if n < 0: + raise ValueError("n must be non-negative number") + total = 0 + value = number + for _ in range(n): + value = value * value + total += value + return total + print("I'm going use the calculator functions to multiply 5 and 6") x = multiply(5,6) print(x) \ No newline at end of file