Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Uncategorized category for Speech Module by bildja
# migrated from python 2.7
def strip_result(checkio_func):
def checkio_wrapper(n):
return checkio_func(n).strip()
return checkio_wrapper
@strip_result
def checkio(n):
if n == 0: return ''
numbers = {
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
10: 'ten',
11: 'eleven',
12: 'twelve',
13: 'thirteen',
14: 'fourteen',
15: 'fifteen',
16: 'sixteen',
17: 'seventeen',
18: 'eighteen',
19: 'nineteen',
20: 'twenty',
30: 'thirty',
40: 'forty',
50: 'fifty',
60: 'sixty',
70: 'seventy',
80: 'eighty',
90: 'ninety',
100: 'hundred'
}
if n == 100:
return 'one hundred'
if n in numbers:
return numbers[n]
if n > 100:
return ' '.join((numbers[n // 100], numbers[100], checkio(n % 100)))
return ' '.join((numbers[(n // 10) * 10], numbers[n % 10]))
if checkio(4) == 'four': print("First done")
if checkio(133) == 'one hundred thirty three': print("Second done")
if checkio(12)=='twelve': print("Third done")
Nov. 14, 2012
Comments: