#pre code set up import random number_of_questions = 0 score = 0 error_str = "Please enter a word out of these options: YES, NO, Y, N " error_int = "Please enter an integer that is between 1 and 50 " max_num = 50 min_num = 1 #instructions while True: try: instructions = input(str("do you want to see the instructions ")) instructions = instructions.lower() if instructions == "y": print("""instructions: insert a number next to the equal sign of the question. Questions will look lik this: 5 x 5 = program will ask how many questions you would like, enter the desired amount and press enter """) break elif instructions == "n": break elif instructions == "yes": print("""instructions: insert a number next to the equal sign of the question. Questions will look lik this: 5 x 5 = program will ask how many questions you would like, enter the desired amount and press enter """) break elif instructions == "no": break else: print(error_str) except ValueError: print(error_str) #how many questions while True: try: count = int(input(f"How many questions do you want between {min_num} and {max_num}? ")) number_of_questions = int(count) if count < min_num: print(error_int) elif count > max_num: print(error_int) #quiz start else: while count >= min_num: try: count -= 1 random_1 = random.randint(2, 15) random_2 = random.randint(2, 15) answer = random_1 * random_2 player_ans = int(input(f"""=================================== {random_1} X {random_2} = """)) if player_ans == answer: score += 1 print("""=================================== Correct""") else: print(f"""=================================== Incorrect, answer was {answer}""") except ValueError: print(error_int) #quiz ends except ValueError: print(error_int) print(f"""=================================== your score is {score} out of {number_of_questions} ===================================""")