## Question

You have 2 tasks:

1. Write pseudocode which clarifies and breaks the code down step by step.

2. Write python code which runs the program.

The actual program you're writing is a math game.

The program chooses from a random set of math problems and if you're correct, you get a "Correct!" message.

If you're incorrect you get a "You got it wrong!" message.

The user can quit by inputting q.

If the user doesn't input a digit, output a syntax error, "Enter an integer.".

The problem

We would like a program that repeatedly displays simple multiplication and division problems, waits for the user's answer, and checks the answer for correctness.

Each multiplication problem will have single-digit operands.

Each division problem shall be the inverse of a multiplication problem with single-digit operands, so that the answer will also be a single digit.

The program will display a prompt character '>' to let the user know it is waiting for an answer.

The program will terminate when the user presses the 'q' key.

These are the kinds of problems it should create:

8 x 9 = ?

63 / 7 = ?

56 / 7 = ?

5 x 0 = ?

It can use the 'x' to represent multiplication and '/' to represent division.

A session may look like

$ mathq

Welcome to the math question program.

4 x 8 = ?

> 32

Correct!

54 / 6 = ?

> 8

You got it wrong! 54 / 6 = 9

7 * 7 = ?

>forty-nine

Enter an integer.

4 * 5 = ?

> q

Thank you for playing mathq. Bye.

$

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import random# print the first message

print('Welcome to the math question program.')

# loop until user enters q

while True:

# chose a random operator / or x

operator = random.randint(0, 1)

# generate random operand

op1 = random.randint(1, 9)

op2 = random.randint(0, 9)

# do multiplication

result...

By purchasing this solution you'll be able to access the following files:

my_math.py and pseduocode.txt.