Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

=+2. What do you think the priorities should be?

Answered: 1 week ago

Question

Are the investments going to be supported by the stakeholders?

Answered: 1 week ago