Question: Implement a program that: Prompts the user for a level, n . If the user does not input 1 , 2 , or 3 ,

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.
Ultimately outputs the users score: the number of correct answers out of 10.
Must include comments with your name, date, program name, and program purpose.
Must include a main function with if __name__=='__main__': code.
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(Note, level represents the number of digits that each operand in the equation should have):
import random
def main():
...
def get_level():
...
def generate_integer(level):
...
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!