Last active
January 24, 2020 15:11
-
-
Save Bundi-py/bfa9ab5afa3223909126e9b586ddc0ce to your computer and use it in GitHub Desktop.
This file contains 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
recnik = {1 : 'jedan', 2 : 'dva', 3 : 'tri', 4 : 'četiri', 5 : 'pet', 6 : 'šest', 7 : 'sedam', 8 : 'osam', | |
9 : 'devet', 10 : 'deset', 11 : 'jedanaest', 12 : 'dvanaest', 13 : 'trinaest', 14 : 'četrnaest', | |
15 : 'petnaest', 16 : 'šesnaest', 17 : 'sedamnaest', 18 : 'osamnaest', 19 : 'devetnaest', | |
20 : 'dvadeset', 30 : 'trideset', 40 : 'četrdeset', 50 : 'pedeset', 60 : 'šezdeset', 70 : 'sedamdeset', | |
80 : 'osamdeset', 90 : 'devedeset', 100 : 'sto', 200 : 'dvesta', 300 : 'trista', 400 : 'četristo', | |
500 : 'petsto', 600 : 'šesto', 700 : 'sedamsto', 800 : 'osamsto', 900 : 'devetsto', 1000 : 'hiljadu'} | |
broj = int(input('Unesi pozitivan broj od 1 do 1000: ')) | |
if 0 < broj < 20: | |
print(recnik.get(broj)) | |
elif broj%10 == 0: | |
print(recnik.get(broj//10 * 10)) | |
elif 21 < broj < 99: | |
print(recnik.get(broj//10 * 10) + ' ' + recnik.get(broj%10)) | |
elif broj%100 == 0: | |
print(recnik.get(broj//100 * 100)) | |
elif 101 < broj < 999: | |
a = broj//100 * 100 | |
b = broj - a | |
if b > 9: | |
print(recnik.get(broj//100 * 100) + ' ' + recnik.get(b//10 * 10) + ' ' + recnik.get(b%10)) | |
else: | |
print(recnik.get(broj//100 * 100) + ' ' + recnik.get(b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment