0

Here is my try of changing integers to English written numbers.

Here corrected version 3 check:

```
from __future__ import print_function
import random,sys
if sys.version_info[0]==3:
raw_input=input
to_19 = ["zero", "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"]
denom = ["", "thousand","million", "billion", "trillion", "quadrillion", "quintillion", "sextillion",
"septillion", "octillion", "nonillion", "decillion", "undecillion", "duodecillion", "tredecillion",
"quattuordecillion", "sexdecillion", "septendecillion", "octodecillion", "novemdecillion", "vigintillion"]
def log1000(n):
" integer log1000 "
res=0
while n>1:
res+=1
n/=1000.0
return res
def inttoeng(number):
unit=log1000(number)-1
if unit>0:
unit_amount,number=divmod(number,1000**unit)
res=(inttoeng(unit_amount)+' '+ denom[unit]+' ')
res+='and ' + inttoeng(number) if number<100 else '' + inttoeng(number)
return res
else:
hundreds,under_100 = divmod(number,100)
ten,unit = divmod(under_100,10)
res=inttoeng(hundreds)+ ' hundred ' if hundreds else ''
if not under_100:
return res
res+='and ' if hundreds and under_100 else ''
res+= tens[ten] if ten>1 else to_19[under_100]
res+= '-'+to_19[unit] if ten>1 and unit else ''
return res
if __name__=='__main__':
for i in range(20):
num = random.randint(0,1e21)
print(num, '=',end=' ')
print(inttoeng(num))
raw_input('Push enter to finish')
```

*Edited 6 Years Ago by pyTony*: n/a