# V3 improve headings, improve the questions, add an explanation of the answers, # remove the percentage and only show the stats at the end # Check that users have entered a valid # option based on a list def string_checker(question, valid_ans): while True: error = f"Enter a valid option from {valid_ans}" user_response = input(question).lower() for item in valid_ans: # check if the user response is a valid answer if item == user_response: return item elif user_response == item[0]: return item print(error) print() def instructions(): print(''' **** Instructions **** To begin, choose the number of questions (minimum is 5, maximum is 10). When the question displays, enter the letter that you think matches the answer. If an invalid letter is entered a helpful hint will be displayed. ''' ) # compare the correct answer v the user input # result - correct or incorrect def rps_compare(user, answer): if user == answer: round_result = "correct" else: round_result = "incorrect" return round_result # checks the input is an integer def int_check(question, low, high): while True: error = f"\U0001F4A1 Hint \U0001F4A1 Enter a number between {low} and {high}" to_check = input(question) try: response = int(to_check) # check the number is between the min and max numbers if low <= response <= high: return response else: print(error) except ValueError: print(error) # Main routine # quiz variables rounds_played = 0 incorrect_answer = 0 correct_answer = 0 yes_no = ["yes", "no"] abcd_list = ['a', 'b', 'c', 'd'] patai_list = ["What is the indigenous language of New Zealand?", "What is the Māori name for New Zealand?", "What is the traditional Māori meeting house called?", "According to Māori, who discovered Aotearoa?", "What is the Māori new year known as?", "Who is the Māori god of the forest?", "What is the traditional Māori cloak made of flax fibers called?", "What is the traditional way Māori cook food?", "What is the traditional Māori way of greeting another person?", "What is a Māori greeting?"] answer_list = ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b'] options_list = ["A. Te Reo Māori\nB. Sign Language\nC. English\nD. Cook Island Māori\n", "A. Wharekauri\nB. Aotearoa\nC. Te Waipounamu\nD. Te ika a Māui\n", "A. Whareiti\nB. Wharekai\nC. Wharenui\nD. Wharepaku\n", "A. Tāne-mahuta\nB. Murirangawhenua\nC. Mahuika\nD. Kupe\n", "A. Matariki\nB. Tupuānuku\nC. Waitā\nD. Tupuārangi\n", "A. Ranginui\nB. Tāne-mahuta\nC. Tangaroa\nD. Rongomātāne\n", "A. Muka\nB. Kākahu\nC. Korowai\nD. Tarau\n", "A. Tuna\nB. Kereru\nC. Waitī\nD. Hāngī\n", "A. Hongi\nB. Hand shake\nC. High five\nD. Mana wave\n", "A. Ka kite\nB. Kia ora\nC. Haere rā\nD. Haere atu\n"] ans_explained = ["Te Reo Māori is the native language of Aotearoa (New Zealand).", "Although Aotearoa is commonly referring to New Zealand, \nThe name was originally used by Māori in reference only to the North Island.", "Wharenui (meeting house) are also known as whare tipuna - ancestral house", "Kupe was a legendary Polynesian explorer who, according to Māori oral history,\n was the first person to discover Aotearoa.", "The appearance of Matariki marks the Māori New Year. It signals a time to remember those who have passed,\n celebrate the present and plan for the future.", "According to the Māori creation story, Tāne-mahuta is the god of the forest and everything that live within it.", "What is the traditional Māori cloak made of flax fibers called?", "A hāngī is a traditional Māori style of cooking using heated rocks,\n steaming the food which is covered with sacks and dirt.", "Hongi is a traditional Māori greeting done when two people press their noses together,\n often includes the touching of the forehead.", "Kia ora is an informal phrase used to greet a person. It can also mean, thank you."] print() print("⚜️ ⚜️ ⚜️ Māori General Knowledge Quiz ⚜️ ⚜️ ⚜️") print() print("** Welcome to the Māori General Knowledge Quiz **") print() # instructions want_instructions = string_checker("Do you want to see the instructions? ", yes_no) if want_instructions == "yes": instructions() num_rounds = int_check("Enter the number of questions, 5 is the minimum, 10 is the maximum ", 5, 10) # game loop starts here while rounds_played < num_rounds: # Heading questions_heading = f"\n*** Question {rounds_played + 1} of {num_rounds} ***" print(questions_heading) print(patai_list[rounds_played]) user_choice = string_checker(options_list[rounds_played], abcd_list) # Random computer choice result = rps_compare(user_choice, answer_list[rounds_played]) # Add counters for the result and the quiz history if result == "correct": correct_answer += 1 feedback = f"\U0001F607\U0001F929 Kei te tika koe! \U0001F929\U0001F607 {ans_explained[rounds_played]}" else: incorrect_answer += 1 feedback = f"🤔💀 Kei te he koe 💀🤔 The correct answer is {answer_list[rounds_played].upper()}. {ans_explained[rounds_played]}" print(feedback) rounds_played += 1 # Display Quiz Stats print() print("**** QUIZ STATS ****") print(f"You correctly answered {correct_answer} out of {rounds_played} questions") print() # Quiz ratings print("**** QUIZ FEEDBACK ****") if correct_answer == num_rounds: print("Ka rawe! - Excellent!") elif num_rounds - 1 >= correct_answer >= num_rounds - 2: print("Tōna pai nei - Not bad") else: print("Aue! Ka aroha - How sad") # End of program message print() print("The Quiz has ended")