Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calculator():
- n = input()
- def summ():
- nums = []
- while len(nums) < 2:
- nums.append(calculator())
- return nums[0] + nums[1]
- def minus():
- nums = []
- while len(nums) < 2:
- nums.append(calculator())
- return nums[0] - nums[1]
- def times():
- nums = []
- while len(nums) < 2:
- nums.append(calculator())
- return nums[0] * nums[1]
- def divide():
- nums = []
- while len(nums) < 2:
- nums.append(calculator())
- return nums[0] // nums[1]
- if n == "+":
- return summ()
- elif n == "-":
- return minus()
- elif n == "*":
- return times()
- elif n == "/":
- return divide()
- else:
- return int(n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement