Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # funcion de conversion |num->alpha|
- def aAlfa(num):
- num = int(num)
- unidades=(
- 'cero',
- 'uno',
- 'dos',
- 'tres',
- 'cuatro',
- 'cinco',
- 'seis',
- 'siete',
- 'ocho',
- 'nueve'
- )
- decenas=(
- 'dieci',
- 'veinti',
- 'treinti',
- 'cuarenti',
- 'cincuenti',
- 'sesenti',
- 'setenti',
- 'ochenti',
- 'noventi'
- )
- excep=(
- 'once',
- 'doce',
- 'trece',
- 'catorce',
- 'quince'
- )
- if num>-1 and num<100:
- if num//10>0:
- if num<16:
- #decenas < 16
- r = excep[(num%10)-1]
- else:
- #decenas > 15
- r = decenas[(num//10)-1]+''+unidades[num%10]
- else:
- #unidades
- r = unidades[num]
- else:
- r = 'Valor fuera de rango!'
- return r
- # main
- cond = True
- print('|Conversor|')
- while cond==True:
- opcion = input('\nOpciones\n\n1. Convertir\n0. Salir\n\n<opcion>: ')
- if opcion == '0':
- cond = False
- print('\nFin de la ejecucion!\n')
- elif opcion == '1':
- r = aAlfa(input('\nIngrese numero entre 0 y 99: '))
- print('\nRepresentacion alfabetica -> '+r)
- else:
- print('\nOpcion no valida!\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement