esperanto_nombroj.py

Created by xanderleadaren

Created on June 12, 2019

541 Bytes

nombro(n) renvoie en espéranto l’écriture en toutes lettres d’un nombre entier n compris entre 1 et 999


num = ["", "unu", "du", "tri",
       "kvar", "kvin", "ses", "sep",
       "ok", "nau"]

def nombro(n):
    u = n % 10
    d = int((n-u) / 10 % 10)
    c = int((n-10*d-u) / 100 % 100)
    if c > 1:
        centoj = num[c] + "cent "
    elif c > 0:
        centoj = "cent "
    else:
        centoj = ""
    if d > 1:
        dekoj = num[d] + "dek "
    elif d > 0:
        dekoj = "dek "
    else:
        dekoj = ""
    if u > 0:
        unuoj = num[u]
    else:
        unuoj = ""
    print(centoj + dekoj + unuoj)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.