Python Quiz and Hacks
Python Quiz and Hacks
This is the quiz that I have made regarding American Football as well as Mr.Mortinson's questions.
import getpass, sys # imports library/ code
from site import ENABLE_USER_SITE # imports from a site
def question_and_answer(prompt): # defines question_and_answer
print("Question: " + prompt) # asks question
msg = input() # get input
print("Answer: " + msg) # prints answer
def question_with_response(prompt):
print("Question: " + prompt)
msg = input()
return msg
questions = 8 # declaring variables
correct = 0
wrong = 0
print('Hey there!, ' + getpass.getuser() + " running " + sys.executable) # program logic beggins
print("You will be asked " + str(questions) + " questions.")
question_and_answer("Are you ready to take a test?") # first question begins
rsp = question_with_response("Who was the quarterback for the Patriots 7 years ago?") # second question
if rsp == "Tom Brady": # if statement starts
print(rsp + " Good Job!")
correct += 1 # adds 1 to correct variable
elif rsp == "Mac Jones": # else if statement
print(rsp + " is the current quarterback, the question asked for 7 years ago.")
wrong += 1 # adds 1 to wrong variable
else: # else statement
print("Your answer of " + rsp + " is incorrect! Here is another question.")
wrong += 1
rsp = question_with_response("Who is the current quarterback for the Patriots?") # third question
if rsp == "Mac Jones":
print(rsp + " is the current quarterback for the New England Patriots!")
correct += 1
else:
print(rsp + " is incorrect!")
wrong += 1
rsp = question_with_response("What position does Aaron Rodgers play?") # fourth question
if rsp == "Quarterback":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
wrong += 1
rsp = question_with_response("Who is the owner of the Patriots football team?") # fifth question
if rsp == "Robert Kraft":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
wrong += 1
rsp = question_with_response("What is the name of the most popular football video game?") #sixth question
if rsp == "Madden":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
wrong += 1
rsp = question_with_response("What command is used to include other functions that are developed?") #Teachers Questions
if rsp == "import":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("What command in this example is used to evaluate a response?")
if rsp == "if":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")
if rsp == "expression":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
percent = (correct/questions) * 100 # finding a perctage
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions) + ". You got " + str(wrong) + " questions wrong. Your percentage on this quiz is " + str(percent) + "%.") # printing out the score and percentage