Math Quiz Maker
Write code that has a variable with a type of math to be quizzed on (addition, subtraction, or multiplication), as well as a number of problems to generate. Make it generate random math problems of the specified type and quantity and then put an answer key after a number of blank lines at the end.
- Specify the math type (1 = addition, 2 = subtraction, 3 = multiplication)
- Math problems should consist of 2 whole number, each between 2 and 12 (e.g. "2 - 6 = ?").
- Put a blank line between each problem displayed
- Set a limit to 50 questions (as a precaution against getting stuck in an infinite loop)
The finished program would output something like this
5 * 2 = ?
2 * 9 = ?
7 * 5 = ?
Answers: 10, 18, 35
Hint: Random number generator code
A random number between 2 and 12 can be generated like this
import random
num = random.randint(2,12)
Hint: Possible structure and code for quiz cycle
for x in range(num_questions):
# Generate and display a question
# Calculate the answer and store it in answer list