import random # Ask how many questions num_questions = int(input("How many multiplication questions would you like? ")) score = 0 # Ask the questions for question in range(1, num_questions + 1): num1 = random.randint(1, 12) num2 = random.randint(1, 12) answer = int(input(f"Question {question}: What is {num1} × {num2}? ")) if answer == num1 * num2: print("Correct!\n") score += 1 else: print(f"Incorrect. The correct answer was {num1 * num2}.\n") # Show results print("Quiz Finished!") print(f"You got {score} out of {num_questions} correct.") percentage = (score / num_questions) * 100 print(f"Your score: {percentage:.1f}%")