Multiplication Quiz
November 13
Objective
To gain experience writing programs with random numbers and nested control structures.
Task
For this assignment, you will write a program to quiz the user on multiplication problems. The program will ask the user how many problems they want to solve, and then generate that many problems randomly. At the end of the problem, it will tell the user how many problems they got right, along with the percentage.
Details
- You should start by asking the user how many problems they want to solve.
- Next ask the user what the smallest and largest numbers they want to multiply by.
- Next, loop as many times as the user requested problems for.
- Each time through the loop, you will need to generate a random problem. This
can be done using
random.randint, passing in the bounds the user set. - For each question, check if they got it right or not. You should give them feedback based on this, including the correct answer when they get it wrong.
- At the end of the problem, you should tell them how many questions they got correct, as well as their percentage (rounded to 2 decimal points).
Example Run
Here is an example run so that you can see how this program will work.
How many problems? 5 What's the smallest number? 1 What's the biggest number? 10 What's 2 times 7? : 14 Correct What's 3 times 6? : 21 No, the answer is 18. What's 3 times 10? : 30 Correct What's 5 times 9? : 45 Correct What's 9 times 10? : 90 Correct You got 4 out of 5. That is 80.0%.
Extra Credit
For extra credit, you can make the quiz ask more than just multiplication questions, such as addition and/or division. You can either ask the user what sorts of questions they want to solve, or you can have it randomly pick what sorts of questions.
General Requirements
When writing your program, also be sure to:
- Put a comment at the top of your program with your name, the name of the program, and the purpose of the program.
- Use good variable names (like "speed" and "time" instead of "x" and "y").
- Test your program before turning it in. Double check the answers your program gives, and check all three difficulty levels!
Submitting
When you are finished, please submit the .py file for the assignment on Canvas.