Week 14 - Variables, Assignments, and Data Abstractions Hacks
A python quiz using stuff from 3.1 and 3.2
def qAndRsp(prompt):
print("Question: " + prompt)
msg = input(prompt)
return msg
questionsList = [
["What language was this coded in?", "python"],
["Sussy", "among us"],
["What letter comes after A in the alphabet?","b"],
["What is 3+4?","7"],
["What is my least favorite class?","csp"],
["aAAAAAaaaaaAaAaaAaaAAaaAAaaAaAaaa", ""],
["I quit", "ok"],
]
correct = 0
questions = len(questionsList)
for QAPair in questionsList:
question = QAPair[0]
answer = QAPair[1]
rsp = qAndRsp(question)
rspLower = rsp.lower()
if rspLower == answer:
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
print("")
quotient=correct/questions
percentage=round((quotient * 100), 2)
print("You scored " + str(correct) +"/" + str(questions))
print("That's", percentage,"%!")
percentList = [
[100,"Perfect!"],
[90,"Great!"],
[80,"Nice!"],
[70,"Could be better"],
[60,"Needs improvement"],
]
for numbersPair in percentList:
numbers = numbersPair[0]
note = numbersPair[1]
if numbers + 10 > percentage >= numbers:
print(note)
if 60 > percentage > 0:
print("Skill issue?")
elif percentage ==0:
print("Very cool!!")