from random import * Questions = [] Answers = [] Counts = [] limit = 3 def Main() : setup() limit = int(input("How many times should I ask a question to make sure you've got it? ")) while numberOfQuestionsLeft() > 0 : qnNum = chooseQuestion() print("\n", Questions[qnNum]) answer = input("True or False? (or quit)") if answer == "quit" : break if answer == Answers[qnNum] : print("you got it right!") Counts[qnNum] = Counts[qnNum]+1 else : print("You got it wrong") Counts[qnNum] = 0 if numberOfQuestionsLeft() == 0 : print("Well Done! You've got them all") else : print("Bye for now, you've still got some practicing to do") # works out how many questions haven't reached the limit and still need to be asked def numberOfQuestionsLeft() : qnCount = 0 for i in Counts : if i < limit : qnCount = qnCount+1 return qnCount # chooses a question at random until it finds one whose count is less than the limit def chooseQuestion(): while True : index = randint(0, len(Counts)-1) if Counts[index] < limit : return index # Sets up the lists of questions def setup() : Questions.append("When are you allowed to pass another vehicle? When you are coming up to a blind corner or blind bend.") Answers.append(False) Counts.append(0) Questions.append("When are you allowed to pass another vehicle? When a vehicle has stopped at a pedestrian crossing.") Answers.apend(False) Counts.append(0) Questions.append("When are you allowed to pass another vehicle? When you can see at least 100 meters of clear road in front of you once you have finished passing.") Answers.append(True) Counts.append(0) Questions.append("When are you allowed to pass another vehicle? When you are less than 10 meters away from a railway level crossing") Answers.append(False) Counts.append(0) Questions.append("Passengers in your vehicle are 15 years of over. Who is responsible for making sure they wear a safety belt? The passengers themselves") Answers.append(True) Counts.append(0) Questions.append("Passengers in your vehicle are 15 years of over. Who is responsible for making sure they wear a safety belt? The parents of the passengers") Answers.append(False) Counts.append(0) Questions.append("Passengers in your vehicle are 15 years of over. Who is responsible for making sure they wear a safety belt? You as the driver of the vehicle") Answers.append(False) Counts.append(0) Questions.append("Passengers in your vehicle are 15 years of over. Who is responsible for making sure they wear a safety belt? Other passengers in your vehicle ") Answers.append(False) Counts.append(0) Questions.append("Which of your vehicle's light do you have on if you are drving in a fog? Park lights") Answers.append(False) Counts.append(0) Questions.append("Which of your vehicle's lights do you have on if you are drving in a fog? Headlights on high beam") Answers.append(False) Counts.append(0) Questions.append("Which of your vehicle's light do you have on if you are drving in a fog? Hazard lights") Answers.append(False) Counts.append(0) Questions.append("Which of your vehicle's light do you have on if you are drving in a fog? Dipped headlights") Answers.append(True) Counts.append(0) Main()