Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert(n):
- if n < 10:
- return placement(n,1)
- elif n == 10:
- return "ten"
- elif n > 10 and n < 20:
- return teen(n)
- elif n >= 20 and n < 100:
- if int(str(n)[1]) == 0:
- return placement(str(n)[0],2)
- else:
- return placement(str(n)[0],2)+convert(int(str(n)[1]))
- elif len(str(n)) == 3:
- x = ""
- h = placement(str(n)[0], 3)
- if int(str(n)[1]) == 0 and int(str(n)[2]) == 0:
- return h
- else:
- z = int(str(n)[1]+"0")+int(str(n)[2])
- x = h + "and" + str(convert(z))
- return x
- elif len(str(n)) == 4:
- x = ""
- t = placement(str(n)[0], 4)
- if int(str(n)[1]) == 0 and int(str(n)[2]) == 0 and int(str(n)[3]) == 0:
- return t
- def teen(n):
- n = int(n)
- if n == 11:
- return "eleven"
- if n == 12:
- return "twelve"
- if n == 13:
- return "thirteen"
- if n == 14:
- return "fourteen"
- if n == 15:
- return "fifteen"
- if n == 16:
- return "sixteen"
- if n == 17:
- return "seventeen"
- if n == 18:
- return "eighteen"
- if n == 19:
- return "nineteen"
- else:
- return ""
- def placement(n,p):
- n = int(n)
- if p == 1:
- if n == 1:
- return "one"
- if n == 2:
- return "two"
- if n == 3:
- return "three"
- if n == 4:
- return "four"
- if n == 5:
- return "five"
- if n == 6:
- return "six"
- if n == 7:
- return "seven"
- if n == 8:
- return "eight"
- if n == 9:
- return "nine"
- else:
- return ""
- if p == 2:
- if n == 1:
- return "ten"
- if n == 2:
- return "twenty"
- if n == 3:
- return "thirty"
- if n == 4:
- return "fourty"
- if n == 5:
- return "fifty"
- if n == 6:
- return "sixty"
- if n == 7:
- return "seventy"
- if n == 8:
- return "eighty"
- if n == 9:
- return "ninety"
- else:
- return ""
- if p == 3:
- if n != 0:
- return placement(n,1) + "hundred"
- else:
- return ""
- if p == 4:
- if n != 0:
- return placement(n,1) + "thousand"
- else:
- return ""
- z = 0
- for x in range(1,1001):
- z += len(convert(x))
- print z
- one
- two
- three
- four
- five
- six
- seven
- eight
- nine
- ten
- eleven
- twelve
- thirteen
- fourteen
- fifteen
- sixteen
- seventeen
- eighteen
- nineteen
- twenty
- twentyone
- twentytwo
- twentythree
- twentyfour
- twentyfive
- twentysix
- twentyseven
- twentyeight
- twentynine
- thirty
- thirtyone
- thirtytwo
- thirtythree
- thirtyfour
- thirtyfive
- thirtysix
- thirtyseven
- thirtyeight
- thirtynine
- fourty
- fourtyone
- fourtytwo
- fourtythree
- fourtyfour
- fourtyfive
- fourtysix
- fourtyseven
- fourtyeight
- fourtynine
- fifty
- fiftyone
- fiftytwo
- fiftythree
- fiftyfour
- fiftyfive
- fiftysix
- fiftyseven
- fiftyeight
- fiftynine
- sixty
- sixtyone
- sixtytwo
- sixtythree
- sixtyfour
- sixtyfive
- sixtysix
- sixtyseven
- sixtyeight
- sixtynine
- seventy
- seventyone
- seventytwo
- seventythree
- seventyfour
- seventyfive
- seventysix
- seventyseven
- seventyeight
- seventynine
- eighty
- eightyone
- eightytwo
- eightythree
- eightyfour
- eightyfive
- eightysix
- eightyseven
- eightyeight
- eightynine
- ninety
- ninetyone
- ninetytwo
- ninetythree
- ninetyfour
- ninetyfive
- ninetysix
- ninetyseven
- ninetyeight
- ninetynine
- onehundred
- onehundredandone
- onehundredandtwo
- onehundredandthree
- onehundredandfour
- onehundredandfive
- onehundredandsix
- onehundredandseven
- onehundredandeight
- onehundredandnine
- onehundredandten
- onehundredandeleven
- onehundredandtwelve
- onehundredandthirteen
- onehundredandfourteen
- onehundredandfifteen
- onehundredandsixteen
- onehundredandseventeen
- onehundredandeighteen
- onehundredandnineteen
- onehundredandtwenty
- onehundredandtwentyone
- onehundredandtwentytwo
- onehundredandtwentythree
- onehundredandtwentyfour
- onehundredandtwentyfive
- onehundredandtwentysix
- onehundredandtwentyseven
- onehundredandtwentyeight
- onehundredandtwentynine
- onehundredandthirty
- onehundredandthirtyone
- onehundredandthirtytwo
- onehundredandthirtythree
- onehundredandthirtyfour
- onehundredandthirtyfive
- onehundredandthirtysix
- onehundredandthirtyseven
- onehundredandthirtyeight
- onehundredandthirtynine
- onehundredandfourty
- onehundredandfourtyone
- onehundredandfourtytwo
- onehundredandfourtythree
- onehundredandfourtyfour
- onehundredandfourtyfive
- onehundredandfourtysix
- onehundredandfourtyseven
- onehundredandfourtyeight
- onehundredandfourtynine
- onehundredandfifty
- onehundredandfiftyone
- onehundredandfiftytwo
- onehundredandfiftythree
- onehundredandfiftyfour
- onehundredandfiftyfive
- onehundredandfiftysix
- onehundredandfiftyseven
- onehundredandfiftyeight
- onehundredandfiftynine
- onehundredandsixty
- onehundredandsixtyone
- onehundredandsixtytwo
- onehundredandsixtythree
- onehundredandsixtyfour
- onehundredandsixtyfive
- onehundredandsixtysix
- onehundredandsixtyseven
- onehundredandsixtyeight
- onehundredandsixtynine
- onehundredandseventy
- onehundredandseventyone
- onehundredandseventytwo
- onehundredandseventythree
- onehundredandseventyfour
- onehundredandseventyfive
- onehundredandseventysix
- onehundredandseventyseven
- onehundredandseventyeight
- onehundredandseventynine
- onehundredandeighty
- onehundredandeightyone
- onehundredandeightytwo
- onehundredandeightythree
- onehundredandeightyfour
- onehundredandeightyfive
- onehundredandeightysix
- onehundredandeightyseven
- onehundredandeightyeight
- onehundredandeightynine
- onehundredandninety
- onehundredandninetyone
- onehundredandninetytwo
- onehundredandninetythree
- onehundredandninetyfour
- onehundredandninetyfive
- onehundredandninetysix
- onehundredandninetyseven
- onehundredandninetyeight
- onehundredandninetynine
- twohundred
- twohundredandone
- twohundredandtwo
- twohundredandthree
- twohundredandfour
- twohundredandfive
- twohundredandsix
- twohundredandseven
- twohundredandeight
- twohundredandnine
- twohundredandten
- twohundredandeleven
- twohundredandtwelve
- twohundredandthirteen
- twohundredandfourteen
- twohundredandfifteen
- twohundredandsixteen
- twohundredandseventeen
- twohundredandeighteen
- twohundredandnineteen
- twohundredandtwenty
- twohundredandtwentyone
- twohundredandtwentytwo
- twohundredandtwentythree
- twohundredandtwentyfour
- twohundredandtwentyfive
- twohundredandtwentysix
- twohundredandtwentyseven
- twohundredandtwentyeight
- twohundredandtwentynine
- twohundredandthirty
- twohundredandthirtyone
- twohundredandthirtytwo
- twohundredandthirtythree
- twohundredandthirtyfour
- twohundredandthirtyfive
- twohundredandthirtysix
- twohundredandthirtyseven
- twohundredandthirtyeight
- twohundredandthirtynine
- twohundredandfourty
- twohundredandfourtyone
- twohundredandfourtytwo
- twohundredandfourtythree
- twohundredandfourtyfour
- twohundredandfourtyfive
- twohundredandfourtysix
- twohundredandfourtyseven
- twohundredandfourtyeight
- twohundredandfourtynine
- twohundredandfifty
- twohundredandfiftyone
- twohundredandfiftytwo
- twohundredandfiftythree
- twohundredandfiftyfour
- twohundredandfiftyfive
- twohundredandfiftysix
- twohundredandfiftyseven
- twohundredandfiftyeight
- twohundredandfiftynine
- twohundredandsixty
- twohundredandsixtyone
- twohundredandsixtytwo
- twohundredandsixtythree
- twohundredandsixtyfour
- twohundredandsixtyfive
- twohundredandsixtysix
- twohundredandsixtyseven
- twohundredandsixtyeight
- twohundredandsixtynine
- twohundredandseventy
- twohundredandseventyone
- twohundredandseventytwo
- twohundredandseventythree
- twohundredandseventyfour
- twohundredandseventyfive
- twohundredandseventysix
- twohundredandseventyseven
- twohundredandseventyeight
- twohundredandseventynine
- twohundredandeighty
- twohundredandeightyone
- twohundredandeightytwo
- twohundredandeightythree
- twohundredandeightyfour
- twohundredandeightyfive
- twohundredandeightysix
- twohundredandeightyseven
- twohundredandeightyeight
- twohundredandeightynine
- twohundredandninety
- twohundredandninetyone
- twohundredandninetytwo
- twohundredandninetythree
- twohundredandninetyfour
- twohundredandninetyfive
- twohundredandninetysix
- twohundredandninetyseven
- twohundredandninetyeight
- twohundredandninetynine
- threehundred
- threehundredandone
- threehundredandtwo
- threehundredandthree
- threehundredandfour
- threehundredandfive
- threehundredandsix
- threehundredandseven
- threehundredandeight
- threehundredandnine
- threehundredandten
- threehundredandeleven
- threehundredandtwelve
- threehundredandthirteen
- threehundredandfourteen
- threehundredandfifteen
- threehundredandsixteen
- threehundredandseventeen
- threehundredandeighteen
- threehundredandnineteen
- threehundredandtwenty
- threehundredandtwentyone
- threehundredandtwentytwo
- threehundredandtwentythree
- threehundredandtwentyfour
- threehundredandtwentyfive
- threehundredandtwentysix
- threehundredandtwentyseven
- threehundredandtwentyeight
- threehundredandtwentynine
- threehundredandthirty
- threehundredandthirtyone
- threehundredandthirtytwo
- threehundredandthirtythree
- threehundredandthirtyfour
- threehundredandthirtyfive
- threehundredandthirtysix
- threehundredandthirtyseven
- threehundredandthirtyeight
- threehundredandthirtynine
- threehundredandfourty
- threehundredandfourtyone
- threehundredandfourtytwo
- threehundredandfourtythree
- threehundredandfourtyfour
- threehundredandfourtyfive
- threehundredandfourtysix
- threehundredandfourtyseven
- threehundredandfourtyeight
- threehundredandfourtynine
- threehundredandfifty
- threehundredandfiftyone
- threehundredandfiftytwo
- threehundredandfiftythree
- threehundredandfiftyfour
- threehundredandfiftyfive
- threehundredandfiftysix
- threehundredandfiftyseven
- threehundredandfiftyeight
- threehundredandfiftynine
- threehundredandsixty
- threehundredandsixtyone
- threehundredandsixtytwo
- threehundredandsixtythree
- threehundredandsixtyfour
- threehundredandsixtyfive
- threehundredandsixtysix
- threehundredandsixtyseven
- threehundredandsixtyeight
- threehundredandsixtynine
- threehundredandseventy
- threehundredandseventyone
- threehundredandseventytwo
- threehundredandseventythree
- threehundredandseventyfour
- threehundredandseventyfive
- threehundredandseventysix
- threehundredandseventyseven
- threehundredandseventyeight
- threehundredandseventynine
- threehundredandeighty
- threehundredandeightyone
- threehundredandeightytwo
- threehundredandeightythree
- threehundredandeightyfour
- threehundredandeightyfive
- threehundredandeightysix
- threehundredandeightyseven
- threehundredandeightyeight
- threehundredandeightynine
- threehundredandninety
- threehundredandninetyone
- threehundredandninetytwo
- threehundredandninetythree
- threehundredandninetyfour
- threehundredandninetyfive
- threehundredandninetysix
- threehundredandninetyseven
- threehundredandninetyeight
- threehundredandninetynine
- fourhundred
- fourhundredandone
- fourhundredandtwo
- fourhundredandthree
- fourhundredandfour
- fourhundredandfive
- fourhundredandsix
- fourhundredandseven
- fourhundredandeight
- fourhundredandnine
- fourhundredandten
- fourhundredandeleven
- fourhundredandtwelve
- fourhundredandthirteen
- fourhundredandfourteen
- fourhundredandfifteen
- fourhundredandsixteen
- fourhundredandseventeen
- fourhundredandeighteen
- fourhundredandnineteen
- fourhundredandtwenty
- fourhundredandtwentyone
- fourhundredandtwentytwo
- fourhundredandtwentythree
- fourhundredandtwentyfour
- fourhundredandtwentyfive
- fourhundredandtwentysix
- fourhundredandtwentyseven
- fourhundredandtwentyeight
- fourhundredandtwentynine
- fourhundredandthirty
- fourhundredandthirtyone
- fourhundredandthirtytwo
- fourhundredandthirtythree
- fourhundredandthirtyfour
- fourhundredandthirtyfive
- fourhundredandthirtysix
- fourhundredandthirtyseven
- fourhundredandthirtyeight
- fourhundredandthirtynine
- fourhundredandfourty
- fourhundredandfourtyone
- fourhundredandfourtytwo
- fourhundredandfourtythree
- fourhundredandfourtyfour
- fourhundredandfourtyfive
- fourhundredandfourtysix
- fourhundredandfourtyseven
- fourhundredandfourtyeight
- fourhundredandfourtynine
- fourhundredandfifty
- fourhundredandfiftyone
- fourhundredandfiftytwo
- fourhundredandfiftythree
- fourhundredandfiftyfour
- fourhundredandfiftyfive
- fourhundredandfiftysix
- fourhundredandfiftyseven
- fourhundredandfiftyeight
- fourhundredandfiftynine
- fourhundredandsixty
- fourhundredandsixtyone
- fourhundredandsixtytwo
- fourhundredandsixtythree
- fourhundredandsixtyfour
- fourhundredandsixtyfive
- fourhundredandsixtysix
- fourhundredandsixtyseven
- fourhundredandsixtyeight
- fourhundredandsixtynine
- fourhundredandseventy
- fourhundredandseventyone
- fourhundredandseventytwo
- fourhundredandseventythree
- fourhundredandseventyfour
- fourhundredandseventyfive
- fourhundredandseventysix
- fourhundredandseventyseven
- fourhundredandseventyeight
- fourhundredandseventynine
- fourhundredandeighty
- fourhundredandeightyone
- fourhundredandeightytwo
- fourhundredandeightythree
- fourhundredandeightyfour
- fourhundredandeightyfive
- fourhundredandeightysix
- fourhundredandeightyseven
- fourhundredandeightyeight
- fourhundredandeightynine
- fourhundredandninety
- fourhundredandninetyone
- fourhundredandninetytwo
- fourhundredandninetythree
- fourhundredandninetyfour
- fourhundredandninetyfive
- fourhundredandninetysix
- fourhundredandninetyseven
- fourhundredandninetyeight
- fourhundredandninetynine
- fivehundred
- fivehundredandone
- fivehundredandtwo
- fivehundredandthree
- fivehundredandfour
- fivehundredandfive
- fivehundredandsix
- fivehundredandseven
- fivehundredandeight
- fivehundredandnine
- fivehundredandten
- fivehundredandeleven
- fivehundredandtwelve
- fivehundredandthirteen
- fivehundredandfourteen
- fivehundredandfifteen
- fivehundredandsixteen
- fivehundredandseventeen
- fivehundredandeighteen
- fivehundredandnineteen
- fivehundredandtwenty
- fivehundredandtwentyone
- fivehundredandtwentytwo
- fivehundredandtwentythree
- fivehundredandtwentyfour
- fivehundredandtwentyfive
- fivehundredandtwentysix
- fivehundredandtwentyseven
- fivehundredandtwentyeight
- fivehundredandtwentynine
- fivehundredandthirty
- fivehundredandthirtyone
- fivehundredandthirtytwo
- fivehundredandthirtythree
- fivehundredandthirtyfour
- fivehundredandthirtyfive
- fivehundredandthirtysix
- fivehundredandthirtyseven
- fivehundredandthirtyeight
- fivehundredandthirtynine
- fivehundredandfourty
- fivehundredandfourtyone
- fivehundredandfourtytwo
- fivehundredandfourtythree
- fivehundredandfourtyfour
- fivehundredandfourtyfive
- fivehundredandfourtysix
- fivehundredandfourtyseven
- fivehundredandfourtyeight
- fivehundredandfourtynine
- fivehundredandfifty
- fivehundredandfiftyone
- fivehundredandfiftytwo
- fivehundredandfiftythree
- fivehundredandfiftyfour
- fivehundredandfiftyfive
- fivehundredandfiftysix
- fivehundredandfiftyseven
- fivehundredandfiftyeight
- fivehundredandfiftynine
- fivehundredandsixty
- fivehundredandsixtyone
- fivehundredandsixtytwo
- fivehundredandsixtythree
- fivehundredandsixtyfour
- fivehundredandsixtyfive
- fivehundredandsixtysix
- fivehundredandsixtyseven
- fivehundredandsixtyeight
- fivehundredandsixtynine
- fivehundredandseventy
- fivehundredandseventyone
- fivehundredandseventytwo
- fivehundredandseventythree
- fivehundredandseventyfour
- fivehundredandseventyfive
- fivehundredandseventysix
- fivehundredandseventyseven
- fivehundredandseventyeight
- fivehundredandseventynine
- fivehundredandeighty
- fivehundredandeightyone
- fivehundredandeightytwo
- fivehundredandeightythree
- fivehundredandeightyfour
- fivehundredandeightyfive
- fivehundredandeightysix
- fivehundredandeightyseven
- fivehundredandeightyeight
- fivehundredandeightynine
- fivehundredandninety
- fivehundredandninetyone
- fivehundredandninetytwo
- fivehundredandninetythree
- fivehundredandninetyfour
- fivehundredandninetyfive
- fivehundredandninetysix
- fivehundredandninetyseven
- fivehundredandninetyeight
- fivehundredandninetynine
- sixhundred
- .....
- ninehundredandninetyseven
- ninehundredandninetyeight
- ninehundredandninetynine
- onethousand
- def teen(n):
- n = int(n)
- if n//10 == 1:
- return ["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"][n-10]
- else:
- return ""
- def placement(n,p):
- n = int(n)
- if n < 1:
- return ""
- if p == 1:
- return ["one","two","three","four","five","six","seven","eight","nine"][n-1]
- if p == 2:
- return ["ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"][n-1]
- if p == 3:
- return placement(n,1) + "hundred"
- if p == 4:
- return placement(n,1) + "thousand"
- def convert(n):
- if n < 10:
- return placement(n,1)
- if n < 20:
- return teen(n)
- if n < 100:
Add Comment
Please, Sign In to add comment