Question
Create a code using python that runs the quiz in the picture below with the same questions. At the end it must calculate the users
Create a code using python that runs the quiz in the picture below with the same questions. At the end it must calculate the users score. I've started on mine and got everything to work except the calculating part at the end. Use my code to finish the program.
To create a running total of the number correct, create a variable to store this score. Set it to zero. With an if statement, add one to the variable each time the user gets a correct answer. (How do you know if they got it correct? Remember that if you are printing out correct then you have already done that part. Just add a line there to add one to the number correct.) Calculate the percentage by using a formula at the end of the game. Don't just add 20% for each question the user gets correct. If you add 20% each time, then you have to change the program 5 places if you add a 6th question. With a formula, you only need 1 change.
PLEASE HELP
MY CODE:
tot = 0
tot = x +1
#harry potter
harrypotter = int(input("How many books are there in the harry potter series? "))
if harrypotter == 7:
#if answer is 7 then it is correct
print("correct")
else:
#if answer is anything other than 7 it is incorrect
print("incorrect")
print("Done")
#math problem
math = int(input("What is 3*(2
-
1)?"))
if math == 3:
#if answer is 3 then print correct
print("correct")
else:
#if answer is anything other than 3 t
hen print incorrect
print("incorrect")
print("Done")
#math problem number 2
math2 = int(input("What is 3*2
-
1?"))
if math2 == 5:
#if answer is 5 then print correct
print("correct")
else:
#if answer is anything other than 5 then print incorrect
print("incorrect")
print("Done")
#multiple choice question
blackhorse = int(input("Who sings Black Horse and the Cherry Tree?
n 1. Kelly Clarkson
n 2. K.T.
Tunstall
n 3. Hillary Duff
n 4. Bon Jovi"))
if blackhorse == 2:
#if answer is 2 then print
correct
print("correct")
else:
#if answer is anything other than 2 then print incorrect
print("incorrect")
print("Done")
#multiple choice question two
dollarbill = int(input("Who is on the front of a one dollar bill
n 1. George Washington
n 2. A
braham
Lincoln
n 3. John Adams
n 4. Thomas Jefferson "))
if dollarbill == 1:
#if answer is 1 then print correct
print("correct")
else:
#if answer is anything other than 1 then print incorrect
print("incorrect")
print("Done")
score = tot1 + tot2 + tot3 + tot4 + tot5
if (score == 20):
print ("Congratulations, you got 1 answer right.")
elif (score == 40):
print ("Congratulations, you got 2 answers right.")
elif (score == 60):
print ("Congratulations, you got 3 answers right.")
el
if (score == 80):
print ("Congratulations, you got 4 answers right.")
elif (score == 100):
else:
print ("Congratulations, you got 5 answers right.")
print ("This is a Score of", score, "percent.")
Quiz time! How many books are there in the Harry Potter series? 7 Correct! What is 3* (2-1)? 3 Correct! What is 3*2-1?!5 Correct! Who sings Black Horse and the Cherry Tree? 1. Kelly Clarkson 2. K.T. Tunstall 3. Hillary Duff 4. Bon Jovi Correct! Who is on the front of a one dollar bill 1. George Washington 2. Abraham Lincoln 3. John Adams 4. Thomas Jefferson No Congratulations, you got 4 answers right That is a score of 86. percentStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started