Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Calc():
- @staticmethod
- def add(x, y):
- return x + y
- .
- .
- .
- @staticmethod
- def div(x, y):
- return x / y
- @staticmethod
- def get_numbers():
- num1 = int(input("Enter first number: "))
- num2 = int(input("Enter second number: "))
- return num1, num2
- @staticmethod
- def get_operator():
- operator = input('Please enter an operator (+, -, *, /): ')
- return operator
- @classmethod
- def calculate(cls):
- cls.get_numbers()
- cls.get_operator()
- if operator == '+':
- print(add(num1, num2))
- elif operator == '-':
- print(sub(num1, num2))
- elif operator == '*':
- print(mul(num1, num2))
- elif operator == '/':
- print(div(num1, num2))
- Calc.calculate()
- Traceback (most recent call last):
- File "calc_feltoltesre.py", line 44, in <module>
- Calc.calculate()
- File "calc_feltoltesre.py", line 32, in calculate
- get_numbers()
- NameError: name 'get_numbers' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement