# -*- 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 """ def math_quiz(): questions_correct = 0 question1 = 1 question2 = 0 question3 = 0 question4 = 0 question5 = 0 question6 = 0 question7 = 0 question8 = 0 print("welcome to the quiz") print("what is your name?") user_name = input() print("question one") while question1 == 1: question_skip = 0 print("What is 2x3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "b" and question_skip == 0): print("You are correct!") question1 = 0 question2 = 1 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "a" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question1 = 0 question2 = 1 user_answer = 0 break print("question two") while question2 == 1: question_skip = 0 print("What is 2+3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "a" and question_skip == 0): print("You are correct!") question2 = 0 question3 = 1 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "b" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question2 = 0 question3 = 1 user_answer = 0 break print("question three") while question3 == 1: question_skip = 0 print("What is 3+3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "b" and question_skip == 0): print("You are correct!") question3 = 0 question4 = 1 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "a" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question3 = 0 question4 = 1 user_answer = 0 break print("question four") while question4 == 1: question_skip = 0 print("What is 3+3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "b" and question_skip == 0): print("You are correct!") question4 = 0 question5 = 1 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "a" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question4 = 0 question5 = 1 user_answer = 0 break print("question five") while question5 == 1: question_skip = 0 print("What is 3+3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "b" and question_skip == 0): print("You are correct!") question5 = 0 question6 = 1 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "a" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question5 = 0 question6 = 1 user_answer = 0 break print("question six") while question6 == 1: question_skip = 0 print("What is 3+3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "b" and question_skip == 0): print("You are correct!") question6 = 0 question7 = 1 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "a" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question6 = 0 question7 = 1 user_answer = 0 break print("question seven") while question7 == 1: question_skip = 0 print("What is 3+3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "b" and question_skip == 0): print("You are correct!") question7 = 0 question8 = 1 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "a" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question7 = 0 question8 = 1 user_answer = 0 break print("question eight") while question8 == 1: question_skip = 0 print("What is 3+3") print("a:5 b:6 c:4 d:3") user_answer = input() if not(user_answer == "a" or user_answer == "b" or user_answer == "c" or user_answer == "d"): print("That is not an answer") question_skip = 1 if(user_answer == "b" and question_skip == 0): print("You are correct!") question8 = 0 user_answer = 0 questions_correct = questions_correct + 1 break elif(user_answer == "a" or user_answer == "c" or user_answer == "d" and question_skip == 0): print("You are wrong") question8 = 0 user_answer = 0 break print( str(user_name) + " got " + str(questions_correct) + "/8 questions correct") if(questions_correct <= 4): print("better luck next time") elif(questions_correct <= 6): print("Good job!") if(questions_correct == 7): print("Great job!") if(questions_correct == 8): print("Superb!")