# -*- coding: utf-8 -*- """ Created on Sun Feb 10 18:16:21 2019 Here is a quiz that asks students multi-choice math questions. Your task is to expand the quiz to include 8 questions. You may edit the existing code however you wish. #Tasks #1)Adapt the quiz to include 8 math questions #2)Adapt the quiz to give better feedback if the user get a question wrong #3)Print a unique message if they get them all correct #4)For a more complete program, ask the user for their name and print out a final report with a total score of correct/incorrect Extension: #E1)Accept the user inputting the numerical value in addition to the multi-choice #Challenge #C1)Use functions to remove the excess use of if statements #C2)Keep track of incorrect answers and the end #C3)Ask the user if they want to resit the test only with questions they got wrong #C4)Randomise the order of questions @author: achuang """ questions = ["What is 1+1: A:2 B:4 C:6 D:8", "What is 2+2: A:2 B:4 C:6 D:8", "What is 3+3: A:2 B:4 C:6 D:8", "What is 4+4: A:2 B:4 C:6 D:8", "What is 5+5: A:10 B:12 C:14 D:16", "What is 6+6 A:10 B:12 C:14 D:16", "What is 7+7 A:10 B:12 C:14 D:16", "What is 8+8 A:10 B:12 C:14 D:16"] question_correct = 0 question_num = 0 question_ans = ["A", "B", "C", "D", "A", "B", "C", "D"] def main(): print("Welcome To The Quiz!") quiz() final_message() def quiz(questions, question_num, question_ans): global questions global question_correct global question_num global question_ans while (question_num <= len(questions)): print(str(questions[question_num])) user_answer = input() user_answer = user_answer.upper() if(user_answer != "A" and user_answer != "B" and user_answer != "C" and user_answer != "D"): print("Please enter a valid input") elif(user_answer == question_ans[question_num]): print("Correct!") question_num = question_num + 1 question_correct = question_correct + 1 else: print("Incorrect!") question_num = question_num + 1 def final_message(question_correct): global questions global question_correct print("What is your name?") user_name = input("") print(str(user_name) + " got " + str(question_correct) + "/" + str(len(questions)) +" questions correct") if(question_correct <= 4): print("better luck next time") elif(question_correct <= 6): print("Good job!") elif(question_correct <= 7): print("Great job!") elif(question_correct <= 8): print("Superb!")