Skip to content

Instantly share code, notes, and snippets.

@ysnerdem
Last active January 18, 2018 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysnerdem/804c8bc0943797c529c312aab2342b69 to your computer and use it in GitHub Desktop.
Save ysnerdem/804c8bc0943797c529c312aab2342b69 to your computer and use it in GitHub Desktop.
Two-digit readings of the Turkish numbers
dict1 = {"1":"on","2":"yirmi","3":"otuz","4":"kırk","5":"elli","6":"altmış","7":"yetmiş","8":"seksen","9":"doksan"}
dict2 = {"0":"","1":"bir","2":"iki","3":"üç","4":"dört","5":"beş","6":"altı","7":"yedi","8":"sekiz","9":"dokuz"}
def read_nums(num):
num = str(num)
if len(num) >= 3 or len(num) < 2:
raise ValueError("...")
for x in dict1:
x = str(x)
if num[0] == x:
for y in dict2:
y = str(y)
if num[1] == y:
return "{}: {} {}".format(num, dict1[x], dict2[y])
while True:
print("**İki basamaklı sayıların okunusu**\nİşlemi q girerek sonlandıra bilirsiniz")
num = input("İki basamaklı bir sayı giriniz:")
if num == "q":
print("İşlem Sonlandırıldı.")
break
try:
print(read_nums(num))
except ValueError:
print("Geçersiz sayı...Lütfen İki basamaklı bir sayı giriniz.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment