Skip to content

Instantly share code, notes, and snippets.

@sinancetinkaya
Created October 24, 2019 02:03
Show Gist options
  • Save sinancetinkaya/8ebcc526c6cf35d661e054f459276581 to your computer and use it in GitHub Desktop.
Save sinancetinkaya/8ebcc526c6cf35d661e054f459276581 to your computer and use it in GitHub Desktop.
verilen sayiyi yaziya cevirir
class YaziyaCevir:
def __init__(self):
self.basamaklar = ["", "bin", "milyon", "milyar", "trilyon", "katrilyon"]
self.sayilar = [
["", "bir", "iki", "uc", "dort", "bes", "alti", "yedi", "sekiz", "dokuz"],
["", "on", "yirmi", "otuz", "kirk", "elli", "altmis", "yetmis", "seksen", "doksan"],
["", "yuz", "ikiyuz", "ucyuz", "dortyuz", "besyuz", "altiyuz", "yediyuz", "sekizyuz", "dokuzyuz"],
]
def cevir(self, sayi):
leading_zeros = 3 - int((len(sayi) / 3)%1 * 3)
sayi = "0" * leading_zeros + sayi
yaziyla = ""
x = 0
y = 0
basamak_yaziyla = ""
for i, n in enumerate(reversed(sayi), 1):
if x == 3 or i == len(sayi):
if len(basamak_yaziyla):
yaziyla = basamak_yaziyla + self.basamaklar[y] + yaziyla
basamak_yaziyla = ""
y +=1
x = 0
basamak_yaziyla = self.sayilar[x][int(n)] + basamak_yaziyla
x += 1
yaziyla = basamak_yaziyla + yaziyla
return yaziyla
if __name__ == "__main__":
yaziyla = YaziyaCevir()
print(yaziyla.cevir("8746541354135413"))
# sekizkatrilyonyediyuzkirkaltitrilyonbesyuzkirkbirmilyarucyuzellidortmilyonyuzotuzbesbindortyuzonuc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment