-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExcer47.py
More file actions
32 lines (27 loc) · 1.08 KB
/
Copy pathExcer47.py
File metadata and controls
32 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Napisz funkcję dzielącą jej argument pierwszy przez drugi.
# Spróbuj wykonać działanie i zwrócić wynik.
# W przypadku błędu dzielenia przez zero, wypisz komunikat o błędzie.
# Wypisz komunikat, który zawsze się wypisze.
# Wywołaj funkcję z różnymi argumentami.
def dzielenie(arg1, arg2):
wynik = 0
try:
wynik = arg1 / arg2
return wynik
except ValueError:
print("Podaj liczbę całkowitą!")
arg1_except = int(input("Podaj liczbę 1: "))
arg2_except = int(input("Podaj liczbę 2: "))
dzielenie(arg1_except, arg2_except)
except ZeroDivisionError as err:
print("Błąd: {}. Błąd dzielenia przez 0! Podaj nowe liczby (bez 0)!".format(err))
arg1_except = int(input("Podaj liczbę 1: "))
arg2_except = int(input("Podaj liczbę 2: "))
dzielenie(arg1_except, arg2_except)
# else:
# print("Wynik dzielenia to: {}".format(arg1 / arg2))
finally:
print("Program zakończony")
l1 = int(input("Podaj liczbę 1: "))
l2 = int(input("Podaj liczbę 2: "))
print(dzielenie(l1, l2))