Created
December 30, 2022 19:53
-
-
Save filipecifali/f8616505cb244f8694f82c9ceb14ab56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def descreve_numero(n): | |
numeros = { | |
0: [ | |
'zero', | |
'um', | |
'dois', | |
'tres', | |
'quatro', | |
'cinco', | |
'seis', | |
'sete', | |
'oito', | |
'nove', | |
], | |
1: [ | |
'dez', | |
'onze', | |
'doze', | |
'treze', | |
'quatorze', | |
'quinze', | |
'dezesseis', | |
'dezessete', | |
'dezoito', | |
'dezenove', | |
], | |
2: [ | |
None, | |
None, | |
'vinte', | |
'trinta', | |
'quarenta', | |
'cinquenta', | |
'sessenta', | |
'setenta', | |
'oitenta', | |
'noventa', | |
], | |
3: [ | |
None, | |
'cem', | |
'duzentos', | |
'trezentos', | |
'quatrocentos', | |
'quinhentos', | |
'seiscentos', | |
'setecentos', | |
'oitocentos', | |
'novecentos', | |
], | |
} | |
str_n = str(n) | |
match len(str_n): | |
case 1: | |
return numeros[0][n] | |
case 2: | |
if len(str_n) == 2 and str_n[0] == '1': | |
return numeros[1][int(str_n[1])] | |
else: | |
if str_n[1] == '0': | |
return numeros[2][int(str_n[0])] | |
else: | |
return ' e '.join([numeros[2][int(str_n[0])], numeros[0][int(str_n[1])]]) |
Author
filipecifali
commented
Dec 30, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment