Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2 . . Write a program (named math_quiz.py) that provides simple math problems to quizzes a student's ability to perform addition and multiplication. Your
Problem 2 . . Write a program (named math_quiz.py) that provides simple math problems to quizzes a student's ability to perform addition and multiplication. Your program has the additional requirements The program shall display a message to the user explaining what the program does. The program shall display a menu where the user can select the type of problems they want. For example 1) Addition problems only 2) Multiplication problems only 3) Random addition & multiplication problems 4) Exit program The program shall display two random numbers from 0 to 100 The program shall present the user with 10 questions of the type they selected. The problems will be formatted and presented to the user in the format: 27 + 19 = After the 10 problems are answered, the program shall display the number of questions answered correctly and the score as a percentage. The program shall return to the menu after summary has been displayed. The program shall NOT display the original display message explaining what the program does. The program shall have the following functions main(): This function is the main codeline and will call all other functions. . display_menu() This function will display the menu to the user get_menu_option(): This function will prompt the user for a menu choice and return a valid option to the calling program. display_problem(num1, num2, operation): This function will accept two numbers and an operator to display the problem to the user. . get_random_number(lower_limit, upper_limit): This function returns a random number bounded by the lower and upper limits. get_user_answer(); This function returns users answer to the problem . display_result(correct_answer, user_answer): This function accepts the correct answer and the user answer to determine the appropriate message to display to the user. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed. display_score (problems_answered_correctly, total_problems): This function accepts the number of questions answered correctly and the total number of problems presented to display a user's summary score. Hint: To generate a random operation, use a random number between 0 and 1. Assign 0 to addition and 1 to multiplication
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