Last active
September 23, 2015 14:39
-
-
Save Ape/78433632ffe71d4e5f4e to your computer and use it in GitHub Desktop.
vaihtoraha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
rahat = [ | |
(10, "kymppiä"), | |
(5, "vitosta"), | |
(2, "kaksieuroista"), | |
(1, "euroa") | |
] | |
hinta = int(input("Ostosten hinta: ")) | |
maksettu = int(input("Maksettu rahasumma: ")) | |
summa = maksettu - hinta | |
if summa <= 0: | |
print("Ei vaihtorahaa") | |
else: | |
for raha in rahat: | |
if summa >= raha[0]: | |
print("{} {}".format(summa // raha[0], raha[1])) | |
summa %= raha[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment