def menu_options(): print() print("options") print("Menu list of Biology General Knowledge quiz") print(" 't' to take the test") print(" 'v' to view the list of questions and answers") print(" 'p' to print options") print(" 'q' to exit the programme") print() def menu(): option = input("Enter your option: ") return option def get_questions(): return[["What is the important sugar in honey? " , "fructose"], ["What is the longest and largest bone in the human body? " , "femur"], ["What is the largest organ in the human body? ", "skin"], ["What is the Ph value of human blood? ", "7.4"], ["What is the rarest human blood group? " "AB negative"]] def check_questions(questions_and_answer): question = questions_and_answer [0] answer = questions_and_answer [1] given_answer = input(question) if answer == given_answer: print("Correct!!") return True else: print("You are a fool! The correct answer 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_questions(questions[index]): right = right +1 index = index + 1 print ("you got", right * 100 / len(questions), "% right out of ", len(questions)) def do_action (choice): if choice == "t": run_test(get_questions()) elif print == "v": print(get_questions()) elif choice == "p": print("Huh...that's some impressive memory...or NOT!") menu_options() elif option == "q": print ("Goodbye!") else: print ("Invalid option! Try again and respect my AUTHORITY!") #Main loop menu_options() while 1==1: option = menu() do_action(option) if option == "q": break
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question