Advertisement
Guest User

Untitled

a guest
Aug 16th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. # Kalkulator
  2.  
  3. def sabiranje(broj1, broj2):
  4.     return broj1 + broj2
  5.  
  6. def oduzimanje(broj1, broj2):
  7.     return broj1 - broj2
  8.  
  9. def mnozenje(broj1, broj2):
  10.     return broj1 * broj2
  11.  
  12. def dijeljenje(broj1, broj2):
  13.     return broj1 / broj2
  14.  
  15.  
  16. print("Izaberi operaciju -\n"
  17.       "1. Sabiranje\n"
  18.       "2. Oduzimanje\n"
  19.       "3. Mnozenje\n"
  20.       "4. Dijeljenje\n")
  21.  
  22. izbor = int(input("Izaberi operaciju 1, 2, 3, 4 :"))
  23.  
  24. broj1 = int(input("Izaberi prvi broj: "))
  25. broj2 = int(input("Izaberi drugi broj: "))
  26.  
  27. if izbor == 1:
  28.     print(broj1, "+", broj2, "=",
  29.           sabiranje(broj1, broj2))
  30.  
  31. elif izbor == 2:
  32.     print(broj1, "-", broj2, "=",
  33.           oduzimanje(broj1, broj2))
  34.  
  35. elif izbor == 3:
  36.     print(broj1, "*", broj2, "=",
  37.           mnozenje(broj1, broj2))
  38.  
  39. elif izbor == 4:
  40.     print(broj1, "/", broj2, "=",
  41.           dijeljenje(broj1, broj2))
  42. else:
  43.     print("Pogresan unos")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement