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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started