hi this is my quiz. what i need to do is add a thing at the start where it askes the user their age. if the user is under the age of 5 they will only be asked 5 question and if there 5 or above they will be asked 10 questions. PLEASE HELP

#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 t?n? 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 motuk? in english",
    "a. Van\nb. Car\nc. Truck\nd. bus\n",
    "c"),
(   "What is whare kotahi in english",
    "a. Deck\nb. Game\nc. Suit\nd. Card\n",
    "d"),
(   "What is haupa in english",
    "a. Food\nb. Drink\nc. Soup\nd. Water\n",
    "a"),
(   "What is Ng? Aho Whakaari 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 inrtuctions 
    print ("""Welcome to the translation quiz
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!!!
""")
    for question, options, correct in question_list:
        print(question)
        print(options)
        #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 

Recommended Answers

All 3 Replies

I think you can try and write it yourself. Obviously you know how to ask the user a question and how to handle an answer, don't you ?

commented: just asking would i start after the instructions +0

this is what i tried but its not working.

#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...""")
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


    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 

nice code , the problem was on line 40 where you missed " at the end of the sentence . also when I ran your code and entered n it did not quit , it should not be hard to fix it

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.