Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. def calculator():
  2.  
  3. n = input()
  4.  
  5. def summ():
  6. nums = []
  7. while len(nums) < 2:
  8. nums.append(calculator())
  9.  
  10. return nums[0] + nums[1]
  11.  
  12. def minus():
  13. nums = []
  14. while len(nums) < 2:
  15. nums.append(calculator())
  16.  
  17. return nums[0] - nums[1]
  18.  
  19. def times():
  20. nums = []
  21. while len(nums) < 2:
  22. nums.append(calculator())
  23.  
  24. return nums[0] * nums[1]
  25.  
  26. def divide():
  27. nums = []
  28. while len(nums) < 2:
  29. nums.append(calculator())
  30.  
  31. return nums[0] // nums[1]
  32.  
  33.  
  34. if n == "+":
  35. return summ()
  36. elif n == "-":
  37. return minus()
  38. elif n == "*":
  39. return times()
  40. elif n == "/":
  41. return divide()
  42. else:
  43. return int(n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement