Mitrezzz

СНЗ Лаб 1 Калкулатор

Nov 3rd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. __operators = ('+','-', '/' , '//', '*', '**', '%')
  2.  
  3.  
  4. def calculator():
  5.     x = eval(input())
  6.     operator = input()
  7.     y = eval(input())
  8.    
  9.     # print(str(x)+operator+str(y))
  10.    
  11.     # your code here
  12.     rezultat = 0
  13.    
  14.     if operator == '+':
  15.         rezultat = x + y
  16.     elif operator == '-':
  17.         rezultat = x - y
  18.     elif operator == '*':
  19.         rezultat = x * y
  20.     elif operator == '//':
  21.         rezultat = x // y
  22.     elif operator == '/':
  23.         rezultat = x / y
  24.     elif operator == '%':
  25.         rezultat = x % y
  26.     elif operator == '**':
  27.         rezultat = x ** y
  28.    
  29.     print(rezultat)
  30.    
  31. if __name__ == "__main__":
  32.     calculator()
  33.  
  34. """
  35. Sample input
  36. 567
  37. %
  38. 5
  39. Sample output
  40. 2
  41. """
Add Comment
Please, Sign In to add comment