File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import math
2+
3+ class Calculator :
4+
5+ def add (self , a , b ):
6+ return a + b
7+
8+ def subtract (self , a , b ):
9+ return a - b
10+
11+ def multiply (self , a , b ):
12+ return a * b
13+
14+ def divide (self , a , b ):
15+ return a / b
16+
17+ # TODO: Implement the following function to calculate the square root of a number.
18+ # def square_root(self, x):
19+ # return math.sqrt(x)
20+
21+ if __name__ == "__main__" :
22+ calculator = Calculator ()
23+
24+ num1 = 16
25+ num2 = 4
26+
27+ print (f"{ num1 } + { num2 } = { calculator .add (num1 , num2 )} " )
28+ print (f"{ num1 } - { num2 } = { calculator .subtract (num1 , num2 )} " )
29+ print (f"{ num1 } * { num2 } = { calculator .multiply (num1 , num2 )} " )
30+ print (f"{ num1 } / { num2 } = { calculator .divide (num1 , num2 )} " )
31+
32+ # TODO: Uncomment and test the square root feature.
33+ # num3 = 25
34+ # print(f"The square root of {num3} = {calculator.square_root(num3)}")
You can’t perform that action at this time.
0 commit comments