Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Little Professor was a calculator that would generate ten different math problems for users to solve. For instance, if the toy were to display 4

Little Professor was a calculator that would generate ten different math problems for users to solve. For instance, if the toy were to display 4+0=, you would (hopefully) answer with 4. If the toy were to display 4+1=, you would (hopefully) answer with 5. If you were to answer incorrectly, the toy would display EEE. And after three incorrect answers for the same problem, the toy would simply display the correct answer (e.g.,4+0=4 or 4+1=5).
Implement a program that:
Prompts the user for a level, n. If the user does not input 1,2, or 3, the program should prompt again.
Randomly generates ten (10) math problems formatted as X + Y =, wherein each of X and Y is a non-negative integer with digits. No need to support operations other than addition (+).
Prompts the user to solve each of those problems. If an answer is not correct (or not even a number), the program should output EEE and prompt the user again, allowing the user up to three tries in total for that problem. If the user has still not answered correctly after three tries, the program should output the correct answer.
The program should ultimately output the users score: the number of correct answers out of 10.
Structure your program as follows, wherein the function get_level prompts (and, if need be, re-prompts) the user for a level and returns 1,2, or 3, and the function generate_integerreturns a randomly generated non-negative integer with level digits or raises a ValueError if level is not 1,2, or 3:

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

User Defined Tensor Data Analysis

Authors: Bin Dong ,Kesheng Wu ,Suren Byna

1st Edition

3030707490, 978-3030707491

More Books

Students also viewed these Databases questions