hi guys i am a beginner to python. Just now completed a few sets of lessons and i'm trying out the exercises given at the end of each chapter. I have learned till the stage of basics in defining a function. But still i am confused.
##This program runs a test of knowledge true = 1 false = 0 def get_questions(): return[["What colour is the daytime sky on a clear day?","blue"],\ ["What is the answer to life, the universe and everything?","42"],\ ["What is a three letter word for mouse trap?","cat"]] def check_question(question_and_answer): question = question_and_answer answer = question_and_answer given_answer = raw_input(question) if answer == given_answer: print "Correct" return true else: print "Incorrect, correct was:",answer return false def run_test(questions): if len(questions) == 0: print "No questions were given." return index = 0 right = 0 while index<len(questions): if check_question(questions[index]): right = right+1 index = index+1 print "You got ",right*100/len(questions),"% right out of",len(questions) run_test(get_questions())
How can i expand this program so that the program has a menu with options to take up the test, viewing the questions and answer and option to quit? Also i need to add a new question to the list for eg., "What noise does a truly advanced machine make?", with the answer of "ping". Thank you.