i'm in desperate need of help.. with this home work keep in mind my professor doesn't know how to teach and I've self tought myself up to this point.
DRIVERS LICENSE EXAM The local drivers license office has asked you to design a program that grades the written portion of the drivers liscense exam. the exam has 20 questions here are the correct answers
- B 6. A 11. B 16. C
- D 7. B 12. C 17. C
- A 8. A 13. D 18. B
- A 9. C 14. A 19. D
- C 10. D 15. D 20. A
Your program should store these correct answers in a array. (store each questions answer in a string array). the program should ask the user to enter the students answers for each 20 questions which should be stored in another array.the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions.
but of course it must be done his way which is
• A def main() that Initializes an array correctAnswers to the answers shown in the problem.
Calls a function userAnswers that accepts user answers to 20 questions and assigns each value to an array. The array should be returned and assigned to a variable userResponses.
Calls a function gradeExam that compares each user response to each correct response. The number of correct answers should be returned.
Calls a function passFail that displays whether the user passed or failed the exam.
this is what i got
#this program stores corect answers for a driver license exam and grades it
def main ():
#list of correct answers
correctAnswers = ["B", "D", "A", "A", "C", "A",
"B", "A", "C", "D", "B", "C",
"D", "A", "D", "C", "C", "B",
"D", "A"]
userAnswers = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
score = 0
def userAnswers():
def gradeAnswers():
print ('you got'), (score), ('correct out of 20.')
print ('Which is'), (20-score), ('wrong out of 20')
def passFail():
if score >= 15:
print("Congratulations!! You passed the exam")
else:
print("Sorry, You Failed")
main()
Aucun commentaire:
Enregistrer un commentaire