MCPcopy Create free account
hub / github.com/CodeWithHarry/The-Ultimate-Python-Course / Calculator

Class Calculator

Chapter 10 - PS/04_problem4.py:1–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Calculator:
2 def __init__(self, n):
3 self.n = n
4
5 def square(self):
6 print(f"The square is {self.n*self.n}")
7
8 def cube(self):
9 print(f"The cube is {self.n*self.n*self.n}")
10
11 def squareroot(self):
12 print(f"The squareroot is {self.n**1/2}")
13
14 @staticmethod
15 def hello():
16 print("Hello there!")
17
18a = Calculator(4)
19a.hello()

Callers 1

04_problem4.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected