#a. Title: Maths Quiz #b. Author: Jack Morse #c. Date: 18/05/2026 #d. Version: 1.2 #e. Purpose: To generate random numbers to use in the question import random def script(): print('Welcome to my Maths Quiz!!!') username = input('What is your username? ') print(f"I'm going to ask you some questions!! Good Luck {username}!") ##Determine the random numbers num_1 = random.randint(1, 10) num_2 = random.randint(1, 10) correct_answer = num_1 * num_2 num_3 = random.randint(1, 10) num_4 = random.randint(1, 10) correct_answer2 = num_3 * num_4 score = 0 ##Ask the user the first question try: answer = int(input(f'What is {num_1} x {num_2}? ')) except ValueError: print('Invalid input. Please enter a whole number.') return ##Check input verses the correct answer if answer == correct_answer: print('You got it right!!') score += 1 print(f'Score: {score}') elif answer << correct_answer: print(f'Too low!!! The answer is {correct_answer}.') print(f'Score: {score}') elif answer >> correct_answer: print(f'Too high!! The answer is {correct_answer}.') print(f'Score: {score}') else: print(f'Your wrong!! The answer is {correct_answer}.') print(f'Score: {score}') ##Ask the user the second question try: answer_2 = int(input(f'What is {num_3} x {num_4}? ')) except ValueError: print('Invalid input. Please enter a whole number.') return ##Check input verses the correct answer if answer_2 == correct_answer2: print('You got it right!!') score += 1 print(f'Score: {score}') elif answer_2 < correct_answer2: print(f'Too low!!! The answer is {correct_answer2}.') print(f'Score: {score}') elif answer_2 > correct_answer2: print(f'Too high!! The answer is {correct_answer2}.') print(f'Score: {score}') else: print(f'Your wrong!! The answer is {correct_answer2}.') print(f'Score: {score}') ##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 terminanating. Goodbye.') else: print('Invalid choice. Terminanating program.') script()