3.1-3.2 Hacks
Notes | Hacks | Grade |
3.1-3.2 Notes | 3.3-3.4 Hacks | |
3.3-3.4 Notes | 3.3-3.4 Hacks | |
3.5-3.7 Notes | 3.5-3.7 Hacks |
quesCount = 0
# Use a dictionary for the questions
quesList = [{"Question1", "What is 1+1 equal to?"}, {"Question2", "What is 2*2 equal to?"}, {"Question3", "What is 3^3 equal to?"}, {"Question4", "What is 4/4 equal to?"}]
print(quesList[0])
# Use a dictionary for the correct solutions
soluList = [{"Solution1"}, {"Solution2"}, {"Solution3"}, {"Solution4"}]
quesAmount= len(quesList)
for i in range(quesAmount):
print(quesList[i], "\n")
guess = input()
if guess == soluList[quesAmount]:
score+=1
print("Correct! Score: ")
else:
print("Incorrect! The correct answer was " + soluList(quesCount) + "\n")
quesCount += 1
print("Final score: " + str(score))
quesCount = 0
score = 0
quesSkip = 0
# Use a dictionary for the questions
quesList = ["What is 1+1 equal to?", "What is 2*2 equal to?", "What is 3/3 equal to?", "What is 4^4 equal to?"]
# Use a dictionary for the correct solutions
soluList = ["2", "4", "1", "256"]
quesAmount= len(quesList)
for i in range(quesAmount):
print(quesList[i])
guess = input("Type 'skip' if you wish to skip the question")
if guess == soluList[i]:
score+=1
print("Your answer", guess, "is correct! Score: ", score, "\n")
elif guess == "skip":
print("You have skipped the question. The correct answer was " + soluList[i]+ "\n")
quesSkip+=1
else:
print("Your answer", guess, "is incorrect! The correct answer was " + soluList[i] + "\n")
quesCount += 1
def percentage(right, wrong):
percentage = 100 * float(right)/float(wrong)
return str(percentage) + "%"
print("You got", score, "questions correct, a", percentage(score, quesCount), "and skipped ", str(quesSkip), "questions")