Python Quiz
points = 0
correct = 0
def q_and_a(prompt):
print ("Question:" + prompt )
msg = input()
return msg
# This code defines the variables and functions
rsp = q_and_a("Name the python output command mentioned in this lesson.")
if rsp == "print":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is not correct.")
rsp = q_and_a("If you see many lines of code in order, what would College Board call it?")
if rsp == "script":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is not correct.")
rsp = q_and_a("Describe a keyword used in Python to define a function.")
if rsp == "def":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is not correct.")
rsp = q_and_a("What command is used to include other functions that were previously developed?")
if rsp == "import":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is not correct.")
rsp = q_and_a("What command is used to evaluate correct or incorrect responses in this example?")
if rsp == "if":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is not correct.")
rsp = q_and_a("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 not correct.")
final = str(correct)
print(final + "/6 Questions" )
#this code presents the exact score on the quiz
pct = correct / 6
fpct = str(pct)
print(fpct + "%")
#this code presents the score as a percent by dividing the correct questions by 6