I think you should use object oriented approach
I made a fairly simple Quiz
class MyQuiz:
def __init__(self, questions, answers):
# both questions and answers should be a list/tuple of string
self.questions = questions
self.answers = answers
self.currentround = 0
def playround(self, roundno):
# roundno is the round number, otherwise correspond with the index
# of the question and answer list/tuple.
# don't use round as variable name as it is a function
return raw_input(self.questions[roundno] + " Your answer: ").lower() == self.answers[roundno].lower()
def mainloop(self):
while self.currentround < len(self.questions):
if (self.playround(self.currentround)):
self.currentround += 1
print "Your answer is correct!"
else:
print "Your answer is wrong!"
print "You have completed the quiz!"
if __name__ == "__main__":
q = ("What year is this?", "What is world's number 1 search engine?", "What language is this quiz programmed in?")
a = ("2010", "Google", "Python")
newGame = MyQuiz(q, a)
newGame.mainloop()
""" Sample OUTPUT from the above program:
What year is this? Your answer: 2010
Your answer is correct!
What is world's number 1 search engine? Your answer: yahoo
Your answer is wrong!
What is world's number 1 search engine? Your answer: google
Your answer is correct!
What language is this quiz programmed in? Your answer: c++
Your answer is wrong!
What language is this quiz programmed in? Your answer: python
Your answer is correct!
You have completed the quiz!
"""
Of course you can have multiple answers,that would be as simple as changing the == in the play round to "in" and remove the lower() at the end. You probably need to prepare them by putting the answer to lower case in the beginning, you can also have error check etc.
Adding new feature is just adding new stuff to the playround function at this point, unless you want GUI, which is a bitch and requires more coding, but it just drawing stuff in the playround and __init__ function, for example, changing the raw_input to getting input from a textbox etc.