Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import operator
  2.  
  3. x = float(input())
  4. y = float(input())
  5. z = input()
  6.  
  7. operations = {
  8.     '+': operator.add,
  9.     '-': operator.sub,
  10.     '*': operator.mul,
  11.     '*': operator.pow,
  12.     '/': operator.truediv,
  13.     '//': operator.floordiv
  14. }
  15.  
  16. try:
  17.     operation = operations[z]
  18.     print(operation(x,y))
  19. except KeyError:
  20.     print("unknown operation")
  21. except ZeroDivisionError:
  22.     print("Деление на 0!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement