
Untitled
Guest 252 7th May, 2024
def wydaj_reszte(do_zaplaty, otrzymana_kwota):
reszta = otrzymana_kwota - do_zaplaty
nominaly = [500, 200, 100, 50, 20, 10, 5, 2, 1]
reszta_w_nominalach = {}
for nominal in nominaly:
ilosc_nominalow = reszta // nominal
if ilosc_nominalow > 0:
reszta_w_nominalach[nominal] = ilosc_nominalow
reszta -= ilosc_nominalow * nominal
return reszta_w_nominalach
# Przykład użycia
do_zaplaty = 123.45
otrzymana_kwota = 200
reszta = wydaj_reszte(do_zaplaty, otrzymana_kwota)
print("Reszta:")
for nominal, ilosc in reszta.items():
print(f"{ilosc} x {nominal} PLN")
To share this paste please copy this url and send to your friends
RAW Paste Data