fork download
  1. def kalkulator():
  2. print("elo to jest kalkulator benc")
  3. print("Wybierz operację:")
  4. print("1. Dodawanie (+)")
  5. print("2. Odejmowanie (-)")
  6. print("3. Mnożenie (*)")
  7. print("4. Dzielenie (/)")
  8.  
  9. operacja = input("Wprowadź operację (+, -, *, /): ")
  10.  
  11. if operacja not in ['+', '-', '*', '/']:
  12. print("Niepoprawna operacja! Spróbuj ponownie.")
  13. return
  14.  
  15. liczba1 = float(input("Podaj pierwszą liczbę: "))
  16. liczba2 = float(input("Podaj drugą liczbę: "))
  17.  
  18. if operacja == '+':
  19. wynik = liczba1 + liczba2
  20. elif operacja == '-':
  21. wynik = liczba1 - liczba2
  22. elif operacja == '*':
  23. wynik = liczba1 * liczba2
  24. elif operacja == '/':
  25. if liczba2 != 0:
  26. wynik = liczba1 / liczba2
  27. else:
  28. print("Pamietaj cholero nie mnozy sie przez 0")
  29. return
  30.  
  31. print(f"Wynik operacji {liczba1} {operacja} {liczba2} = {wynik}")
Success #stdin #stdout 0.04s 9556KB
stdin
Standard input is empty
stdout
Standard output is empty