Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer this completely and provide the code for the convert(number_str) function. The code provided is in the second picture. 3. Four is magic. Write

Please answer this completely and provide the code for the convert(number_str) function. The code provided is in the second picture.
image text in transcribed
image text in transcribed
3. Four is magic. Write a Python program (called q3.py) that given an integer from 0 to 1,000 does the "4 is magic" transformation. The steps are as follows. a) Convert the integer n into English and count the number of letters (i.e. 21 is twenty one' and consists of 9 letters, 102 is "one hundred two" and consists of 13 letters, 1000 is "one thousand" and consists of 11 letters). b) Let nen be the length of the English word equivalent for the integer n. i. If nien is 4, output "four is magic." Then, terminate the transformation pro- ii. Otherwise output "English word equivalent of integer n> is " Re- Suppose the user inputs the integer 26. Then, the transformation proceeds as follows. cess peat step (a), where the integer n is set to men- twenty six is 9. where twenty six is the 9-letter English word equivalent of 26. nine is where ninc is the 4-letter English word equivalent of 9 .four is magic Example. User input is shown on lines with the > symbol. Ou line 1, the user enters 26 and the computer outputs the results of the transformation process (lines 2 4). The user then enters 3 (line 5) and the program outputs the result of the transformation process (lines 6 8), The user enters 813 (line 9) and the resulting output is shown (lines 10-13). Finally, the user types quit (line 14) and the program terminates 26 2 twenty six is 9 snine is 4. four is magic othree is 5 7 five isA sfour is magic 843

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions