Advertisement
MAKNINMISHA

Untitled

Mar 27th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 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. minus = False
  10. if n == 0:
  11. word = "zero"
  12. if n < 0 :
  13. n = -n
  14. minus = True
  15. while n > 0:
  16. s = n % 1000
  17. if up_change > 0 and s > 0:
  18. if s <= 9 :
  19. o = s % 10
  20. word = ones[o] + orders[up_change] + word
  21. if s < 20 and s > 9:
  22. te = s % 10
  23. word = teens[te] + orders[up_change] + word
  24. if s <= 99 and s >= 20:
  25. o = s % 10
  26. t = (s // 10) % 10
  27. word = tens[t] + ones[o] + orders[up_change] + word
  28. if s <= 999 and s >=100 :
  29. o = s % 10
  30. t = (s // 10) % 10
  31. oh = (s // 100) % 10
  32. word = ones[oh] + h + tens[t] + ones[o] + orders[up_change] + word
  33. elif up_change == 0 and s > 0:
  34. if s <= 9 and s > 0 :
  35. o = s % 10
  36. word = ones[o] + word
  37. if s < 20 and s > 9:
  38. te = s % 10
  39. word = teens[te] + word
  40. if s <= 99 and s >= 20:
  41. o = s % 10
  42. t = (s // 10)%10
  43. word = tens[t] + ones[o] + word
  44. if s <= 999 and s >= 100:
  45. if 9 < (s % 100) and (s % 100) < 20:
  46. te = s % 10
  47. oh = (s // 100) % 10
  48. word = ones[oh] + h + teens[te] + word
  49. else:
  50. o = s % 10
  51. t = (s // 10) % 10
  52. oh = (s // 100) % 10
  53. word = ones[oh] + h + tens[t] + ones[o] + word
  54. up_change +=1
  55. n = n // 1000
  56. if not minus:
  57. print(word)
  58. else:
  59. print("minus " + word )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement