Sayıdan Kelimeye
Sayıları İngilizce kelimelere dönüştürün (örn: 1234 → one thousand two hundred thirty-four).
Sıkça Sorulan Sorular
Kod Uygulaması
# Number to words using the num2words library
# Install: pip install num2words
from num2words import num2words
# Basic conversion (English)
print(num2words(42)) # forty-two
print(num2words(1000000)) # one million
print(num2words(1234567)) # one million, two hundred and thirty-four thousand,
# five hundred and sixty-seven
# Ordinal numbers
print(num2words(1, to='ordinal')) # first
print(num2words(42, to='ordinal')) # forty-second
print(num2words(100, to='ordinal')) # one hundredth
# Other languages
print(num2words(42, lang='de')) # zweiundvierzig
print(num2words(42, lang='fr')) # quarante-deux
print(num2words(42, lang='es')) # cuarenta y dos
print(num2words(42, lang='ja')) # 四十二
# Currency (year) mode
print(num2words(2024, to='year')) # twenty twenty-four
# Without the library: simple custom implementation
ones = ['', 'one', 'two', 'three', 'four', 'five', 'six',
'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve',
'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen',
'eighteen', 'nineteen']
tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty',
'sixty', 'seventy', 'eighty', 'ninety']
def number_to_words(n: int) -> str:
if n == 0: return 'zero'
if n < 0: return 'negative ' + number_to_words(-n)
if n < 20: return ones[n]
if n < 100:
return tens[n // 10] + (('-' + ones[n % 10]) if n % 10 else '')
if n < 1000:
rest = number_to_words(n % 100)
return ones[n // 100] + ' hundred' + (' and ' + rest if rest else '')
if n < 1_000_000:
rest = number_to_words(n % 1000)
return number_to_words(n // 1000) + ' thousand' + (', ' + rest if rest else '')
rest = number_to_words(n % 1_000_000)
return number_to_words(n // 1_000_000) + ' million' + (', ' + rest if rest else '')
print(number_to_words(42)) # forty-two
print(number_to_words(100)) # one hundred
print(number_to_words(1234)) # one thousand, two hundred and thirty-fourComments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.