MAKNINMISHA

Untitled

Mar 27th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. n = int(input())
  2. up_change = 0
  3. ones = ["", "one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine "]
  4. teens = ["ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen "]
  5. tens = ["","", "twenty ", "thirty ", "forty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety "]
  6. orders = ["","thousand ", "million ", "billion "]
  7. h = "hundred "
  8. word = ""
  9. while n > 0:
  10. s = n % 1000
  11. if up_change > 0 and s > 0:
  12. if s <= 9:
  13. o = s % 10
  14. word = ones[o] + orders[up_change] + word
  15. if s < 20 and s > 9:
  16. te = s % 10
  17. word = teens[te] + orders[up_change] + word
  18. if s <= 99 and s >= 20:
  19. o = s % 10
  20. t = (s // 10) % 10
  21. word = tens[t] + ones[o] + orders[up_change] + word
  22. if s <= 999 and s >=100 :
  23. o = s % 10
  24. t = (s // 10) % 10
  25. oh = (s // 100) % 10
  26. word = ones[oh] + h + tens[t] + ones[o] + orders[up_change] + word
  27. else:
  28. if n == 0:
  29. word = "zero"
  30. break
  31. if s <= 9 :
  32. o = s % 10
  33. word = ones[o] + word
  34. if s < 20 and s > 9:
  35. te = s % 10
  36. word = teens[te] + word
  37. if s <= 99 and s >= 20:
  38. o = s % 10
  39. t = (s // 10)%10
  40. word = tens[t] + ones[o] + word
  41. if s <= 999 and s >= 100:
  42. if 9 < (s % 100) and (s % 100) < 20:
  43. te = s % 10
  44. oh = (s // 100) % 10
  45. word = ones[oh] + h + teens[te] + word
  46. else:
  47. o = s % 10
  48. t = (s // 10) % 10
  49. oh = (s // 100) % 10
  50. word = ones[oh] + h + tens[t] + ones[o] + word
  51. up_change +=1
  52. n = n // 1000
  53. print(word)
Add Comment
Please, Sign In to add comment