General
Write a function to convert an integer number to the word representation.
We should handle zero:
>>> num_word(0)
'zero'
And numbers under a thousand:
>>> num_word(2)
'two'
>>> num_word(-2)
'negative two'
>>> num_word(11)
'eleven'
>>> num_word(20)
'twenty'
>>> num_word(100)
'one hundred'
>>> num_word(121)
'one hundred twenty one'
And numbers over a thousand:
>>> num_word(1256)
'one thousand two hundred fifty six'
>>> num_word(100001)
'one hundred thousand one'
>>> num_word(1000000)
'one million'
And all numbers ranging from -999,999,999,999 to 999,999,999,999 (you can stop there):
>>> num_word(-1234567890)
'negative one billion two hundred thirty four million
five hundred sixty seven thousand eight hundred ninety'
>>> num_word(999999999999)
'nine hundred ninety nine billion nine hundred ninety nine million
nine hundred ninety nine thousand nine hundred ninety nine'
We’ve provided a file, numword.py, with a function, num_word:
def num_word(num):
"""Convert word to number."""
This is just a stub, though—implement it.