#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 print('Welcome to my Maths Quiz!!!') username = input('What is your username? ') def script(): while True: try: question_num = int(input('How many questions do you want? (0-50) ')) if question_num < 1 or question_num > 50: print('Please enter a number between 0 and 50') else: break except ValueError: print('Invalid input. Please enter a whole number.') print(f"Ok! Good Luck {username}!") ##Determine the random numbers score = 0 for question in range(question_num): num_1 = random.randint(1, 10) num_2 = random.randint(1, 10) correct_answer = num_1 * num_2 ##Ask the user the first question while True: try: answer = int(input(f'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: print('You got it right!!') score += 1 elif answer < correct_answer: print(f'Too low!!! The answer is {correct_answer}.') else: print(f'Too high!! The answer is {correct_answer}.') percentage = (score / question_num) * 100 print(f'Your score is {score}/{question_num} which is {percentage}%') ##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.') script()