Write a program that allows the user to practice multiplication. Ask the user how many problems they want and then give the user that many problems. Each number in the problem should be in between 1 and 10, inclusive. For each question, determine if the user got the question correct. At the end of the game print out the percentage of problems they got correctly, rounded to the nearest tenth of a percent. After each question, print out a message with one of the two following formats, depending on whether or not the user correctly answered the question (where X represents the correct answer to the question:
Correct!
Sorry, the answer is X.
This is how the answer for the problem such come out...
Sample Program Run:
How many problems do you want?
6
What is 1 x 4?
4
Correct!
What is 6 x 10?
60
Correct!
What is 5 x 10?
50
Correct!
What is 10 x 2?
20
Correct!
What is 3 x 9?
24
Sorry, the answer is 27.
What is 5 x 7?
35
Correct!
You got 83.3% of the problems.
I have this so far...
import random
def main():
random.seed()
Varibale_1 = random.radint (1,10)
Variable_2 = random.radint (1,10)
# Get the user input.
problems_want = int(input("How many problems do you want?\n"))
# Calculate the correct answer for the problem.
product = int(input("What is"+str(Variable_1)+" x "+str(Variable_2)+"?")
problem_answer = Variable_1 * Variable_2
If product = problem_answer:
print("Corret!")
else:
print("Sorry, the answer is",,".",sep="")
average =
print("You got","%.1f"%average,"of the problems.")

New Topic/Question
Reply



MultiQuote



|