Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment 1) Implement the functions below (#1-4) an answer the question for #5 in the file a3.py 2) Submit your a3.py file 3) You must
Assignment 1) Implement the functions below (#1-4) an answer the question for #5 in the file a3.py 2) Submit your a3.py file 3) You must also write doc strings for every function. See page 72 in the text. A submission without doc strings will not earn full credit 1. (Marcus) One of the basic rules of writing is that small numbers should be written out as words, so you should not write "I have 4 cards", but "I have four cards", and "The temperature is 0 degrees" should be "The temperature is zero degrees." We want to implement a function that convers text in this way. We'l do this in two steps. a) [10pt] Implement a function number_word(n) that takes as an input a number n and returns the corresponding number word for integer numbers 0- n9. For any other value, simply return n itself. Hint: do not use an if elif cascade, use a list b) [10pt] Implement a function edit(s) that does the following: it takes the string s and replaces all occurrences of numbers n between 0 n9 with the corresponding words. You can assume that your text does not contain any numbers>10. Hint: use a loop, and use your function from a). To change the string, use the strings replace0 method, you don't have to use the split() method (you can, if you want to). See output below (including erroneous handling of 10. which is fine) Python Shell File Edit Shel Debug Options Windows Help >>number word (4) four >>>number word (9) 'nine' umber word (10) 10 >>> edit ('I have 4 cards, 1 king, 2 queens, and 1 10) I have four cards, one king, two queens, and one onezero Ln: 62 Cot 4
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