rhys1619 0 Newbie Poster

hi there what i've tried a lot is to make it so at the start of the quiz it asks the user there age. if the user is under 5 they will only be asked 5 questions and if there over 5 they will be asked all 10

#rhys translation quiz
#the list of questions that will be asked
question_list = [
(   "What is Kia ora in english",
    "a. Hello\nb. Bye\nc. Greetings\nd. See ya\n",
    "a"),
(   "What is tena rawa atu koe in english",
    "a. Give it\nb. bye\nc. Thank you\nd. See ya\n",
    "c"),
(   "What is rorohiko in english",
    "a. TV\nb. Microwave\nc. Oven\nd. Computer\n",
    "d"),
(   "What is taraka in english",
    "a. Van\nb. Car\nc. Truck\nd. bus\n",
    "c"),
(   "What is kāri in english",
    "a. Deck\nb. Game\nc. Suit\nd. Card\n",
    "d"),
(   "What is kai in english",
    "a. Food\nb. Drink\nc. Soup\nd. Water\n",
    "a"),
(   "What is kiriata in english",
    "a. Show\nb. Film\nc. Song\nd. Book\n",
    "b"),
(   "What is makawe in english",
    "a. Face\nb. Hair\nc. Neck\nd. Beard\n",
    "b"),
(   "What is tau in english",
    "a. Letter\nb. Number\nc. Space\nd. Shape\n",
    "b"),
(   "What is wini in english",
    "a. Win\nb. Lose\nc. Try again\nd. Quit\n",
    "a"),
]
play_again = True
while play_again:
    score = 0
#intro and instruction
print ("""Welcome to the translation quiz...""")
#new input function here. You can make the message more or less formal
age = int(input("Please enter your age: ))
print ("""You will be ask a series of questions and have 2 tries per questions
If you get the correct answer you will get one point, half a point for getting it
your second try and zero points if you get it wrong twice.
GOOD LUCK!!!
""")

counter = 0
for question, options, correct in question_list:
    print(question)
    print(options)
    if counter == 5 and age <= 5:
     #if you reach the 5th question then you want to break the for loop.
        break

    #increment the variable to keep track of position
    counter +=1
        #user will have to enter a,b,c or d for there answer
        response = input("Hit 'a', 'b', 'c' or 'd' for your answer\n")
        #simple, if answer is correct print correct and move on to next question, if not try again
        if response.lower() == correct:
            print ("Correct\n")
            score = score + 1
            #this will say there wrong and they will get another try. if they get it right they get 0.5 points and if not they move on to the next question
        else:
            print("Wrong. Try again.\n")
            response = input("Hit 'a', 'b', 'c' or 'd' for your answer\n")
            if response.lower() == correct:
                print ("Correct\n")
                score = score + 0.5
            else:
                print("Wrong. You ran out of attempts\n")
                #this will print the users final score out of 10
    print ("Your score was", str (score)+"/10")
    #this is a restart. if the user says y then they restart if not the program ends.
    response = input("Do you want to play again (y/n)?").strip().lower()
    if response not in ('', 'y', 'yes'):
        play_again = False 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.