In: Computer Science
Program:
correctAnswers=["B","D","A","A","C","A","B","A","C","D","B","C","D","A","D","C","C","B","D","A"]
studentAnswers = []
questionNums=[]
i = 1
print("Enter your answers : ")
while (i <= 20):
answer = input() # Taking answers input from user
if (answer == "A" or answer == "B" or answer == "C" or answer == "D"):
studentAnswers.append(answer)
i = i + 1
else:
print("Please enter a valid answer")
for x in range(20):
if correctAnswers[x] != studentAnswers[x]: # Comparing the answers
questionNums.append(x+1)
if len(questionNums) > 5:
print("Oops!! You have failed the exam")
else:
print("Yayy!! You have passed the exam")
# Printing output
print("Total corrected answers :", 20-len(questionNums))
print("Total incorrected answers :", len(questionNums))
print("Incorrected question numbers list :", questionNums)
Output: