Question: 2. Write a function `in_words' that takes a number as input and produces the same number in words. For example, in_words(0) == zero in_words(11) ==

2. Write a function `in_words' that takes a number as input and produces the same number in words. For example, in_words(0) == "zero" in_words(11) == "eleven" in_words(91) == "ninety-one" Try and handle at least all numbers from 0 to 99. This can be done by an if-elif-else with 100 branches. Think of a better way. Can you extend your function to handle all numbers from 0 to 9999? Here are some useful tips: n % 10 gives the digit in the units place and n // 10 gives the number after removing the digit in the units place. 3. Modify the pluralize function to use in_words. i.e., pluralize("dog", 99) == "ninety-nine dogs"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!