Azure47

SNZ Lab 1.1

Oct 8th, 2019
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. __operators = ('+', '-', '/', '//', '*', '**', '%')
  3.  
  4.  
  5. def calculator():
  6.     x = input()
  7.     operator = input()
  8.     y = input()
  9.  
  10.     rezultat = 0
  11.     if operator == "+":
  12.         rezultat = int(x) + int(y)
  13.     elif operator == "-":
  14.         rezultat = int(x) - int(y)
  15.     elif operator == "*":
  16.         rezultat = int(x) * int(y)
  17.     elif operator == "//":
  18.         rezultat = int(x) / int(y)
  19.     elif operator == "/":
  20.         rezultat = float(x) / float(y)
  21.     elif operator == "%":
  22.         rezultat = int(x) % int(y)
  23.     elif operator == "**":
  24.         rezultat = int(x) ** int(y)
  25.     else:
  26.         print("Error")
  27.         return 0
  28.     print(rezultat)
  29.     return rezultat
  30.  
  31.  
  32. if __name__ == "__main__":
  33.     calculator()
Advertisement
Add Comment
Please, Sign In to add comment