Question: Math Quiz (adapted from #11) Save the file as ch5_ex2.py A multiplicand and a multiplier are multiplied to achieve a product in multiplication. Multiplicand 15
Math Quiz (adapted from #11) Save the file as ch5_ex2.py
A multiplicand and a multiplier are multiplied to achieve a product in multiplication.
Multiplicand 15 Multiplier 3 Product 45
Write a program that gives simple math quizzes. The program should display the multiplicand (random number between 0 and 99) and the multiplier (random number between 0 and 9). The program should allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a statement showing the correct response should be displayed.
Your program must:
Import the random module from the standard library. (See section 5.7 on page 250.)
Include the function display_problem() that accepts the numbers and displays them formatted exactly like the example output below.
Include the function get_answer(), which prompts the user to answer.
Include the function show_result(), which accepts the correct answer and student's answer and provides the correct or incorrect feedback like shown in the example output.
The output should look like this for a correct answer: 54 4 --- Enter product: 216 Correct answer Good Work!
The output should look like this for an incorrect answer: 45 0 --- Enter product: 45 Incorrect. The correct answer is: 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
