#a. Title: Maths Quiz #b. Author: Jack Morse #c. Date: 18/05/2026 #d. Version: 1.4 #e. Purpose: To use the user testing tips to improve my program import random ##Ask the username and welcome the user print('Welcome to my Maths Quiz!!!') username = input('What is your username? ') ##Start the program def script(): while True: try: question_num = int(input('How many questions do you want? (0-15) ')) if question_num < 1 or question_num > 15: print('Please enter a number between 0 and 15') else: break except ValueError: print('Invalid input. Please enter a whole number.') print(f"Ok! Good Luck {username}!") ##Determine the random numbers question_marker = 0 score = 0 history_list = [] for question in range(question_num): num_1 = random.randint(1, 10) num_2 = random.randint(1, 10) correct_answer = num_1 * num_2 question_marker += 1 ##Ask the user the first question while True: try: answer = int(input(f'{question_marker}: What is {num_1} x {num_2}? ')) if answer < 0 or answer > 100: print('Please enter a number between 1 and 100.') else: break except ValueError: print('Invalid input. Please enter a whole number.') ##Check input verses the correct answer if answer == correct_answer: message_result = 'You got it right!!' print(message_result) score += 1 elif answer < correct_answer: message_result = f'Too low!!! The answer is {correct_answer}.' print(message_result) else: message_result = f'Too high!!! The answer is {correct_answer}.' print(message_result) history_list.append(message_result) ##Display percentage percentage = (score / question_num) * 100 print(f'Your score is {score}/{question_num} which is {percentage}%') ##Ask if the user wants to see their history see_history = input('Do you want to see your quiz history? ') if see_history == 'yes' or see_history == 'y': print(*history_list, sep='\n') ##Restart the program restart = input('Would you like to restart the program? (y/n) ') if restart == 'yes' or restart == 'y': script() elif restart == 'no' or restart == 'n': print('Script terminating. Goodbye.') else: print('Invalid choice. Terminating program.') ##Close the program script()