Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def SpellOutInt0to999InEN(input):
- and_ = False
- en = ""
- ones = ""
- tens = ""
- hundreds = ""
- if input // 100 == 0:
- hundreds = ""
- elif input // 100 == 1:
- hundreds = "one hundred"
- elif input // 100 == 2:
- hundreds = "two hundred"
- elif input // 100 == 3:
- hundreds = "three hundred"
- elif input // 100 == 4:
- hundreds = "four hundred"
- elif input // 100 == 5:
- hundreds = "five hundred"
- elif input // 100 == 6:
- hundreds = "six hundred"
- elif input // 100 == 7:
- hundreds = "seven hundred"
- elif input // 100 == 8:
- hundreds = "eight hundred"
- elif input // 100 == 9:
- hundreds = "nine hundred"
- if (input % 100) // 10 == 0:
- tens = ""
- elif (input % 100) // 10 == 1:
- tens = "ten"
- elif (input % 100) // 10 == 2:
- tens = "twenty"
- elif (input % 100) // 10 == 3:
- tens = "thirty"
- elif (input % 100) // 10 == 4:
- tens = "forty"
- elif (input % 100) // 10 == 5:
- tens = "fifty"
- elif (input % 100) // 10 == 6:
- tens = "sixty"
- elif (input % 100) // 10 == 7:
- tens = "seventy"
- elif (input % 100) // 10 == 8:
- tens = "eighty"
- elif (input % 100) // 10 == 9:
- tens = "ninety"
- if input % 10 == 0:
- ones = ""
- elif input % 10 == 1:
- ones = "one"
- elif input % 10 == 2:
- ones = "two"
- elif input % 10 == 3:
- ones = "three"
- elif input % 10 == 4:
- ones = "four"
- elif input % 10 == 5:
- ones = "five"
- elif input % 10 == 6:
- ones = "six"
- elif input % 10 == 7:
- ones = "seven"
- elif input % 10 == 8:
- ones = "eight"
- elif input % 10 == 9:
- ones = "nine"
- if tens == "" and ones == "":
- en = "zero" if hundreds == "" else hundreds
- elif tens == "ten":
- if ones == "":
- en = "ten"
- elif ones == "one":
- en = "eleven"
- elif ones == "two":
- en = "twelve"
- elif ones == "three":
- en = "thirteen"
- elif ones == "four":
- en = "fourteen"
- elif ones == "five":
- en = "fifteen"
- elif ones == "six":
- en = "sixteen"
- elif ones == "seven":
- en = "seventeen"
- elif ones == "eight":
- en = "eighteen"
- elif ones == "nine":
- en = "nineteen"
- if hundreds != "":
- en = hundreds + (" and " if and_ else " ") + en
- else:
- en = ones
- if tens != "":
- en = tens + ("" if ones == "" else " " + en)
- if hundreds != "":
- en = hundreds + (" and " if and_ else " ") + en
- return en
- n = int(input())
- print(SpellOutInt0to999InEN(n) if 0 <= n <= 100 else "invalid number")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement