Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. class Calc():
  2.  
  3. @staticmethod
  4. def add(x, y):
  5. return x + y
  6.  
  7. .
  8. .
  9. .
  10.  
  11. @staticmethod
  12. def div(x, y):
  13. return x / y
  14.  
  15. @staticmethod
  16. def get_numbers():
  17. num1 = int(input("Enter first number: "))
  18. num2 = int(input("Enter second number: "))
  19. return num1, num2
  20.  
  21. @staticmethod
  22. def get_operator():
  23. operator = input('Please enter an operator (+, -, *, /): ')
  24. return operator
  25.  
  26. @classmethod
  27. def calculate(cls):
  28. cls.get_numbers()
  29. cls.get_operator()
  30. if operator == '+':
  31. print(add(num1, num2))
  32. elif operator == '-':
  33. print(sub(num1, num2))
  34. elif operator == '*':
  35. print(mul(num1, num2))
  36. elif operator == '/':
  37. print(div(num1, num2))
  38.  
  39.  
  40. Calc.calculate()
  41.  
  42. Traceback (most recent call last):
  43. File "calc_feltoltesre.py", line 44, in <module>
  44. Calc.calculate()
  45. File "calc_feltoltesre.py", line 32, in calculate
  46. get_numbers()
  47. NameError: name 'get_numbers' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement