Objectives

  • Develop algorithms to solve problems
  • Demonstrate ability to execute a python script
  • Accept inputs from the console/terminal
  • Write and execute mathematical expressions in python
  • Demonstrate ability to use simple scripting constructs: conditional statements and loops etc.
  • Work with Boolean/Logical Operators

The overall purpose of this lab is to provide students an overview of the basic Python scripting concepts.

Problem

The Motor Vehicle Administration has asked you to write a script that grades the written portion of the Driver's License exam. The Exam has a 10 multiple choice questions with the answers for the questions 110 respectively shown in the list below;

A B D A B B B C C D

Your script should store the correct answer shown above in a list. It should then ask for each student's ID and answers for the 10 questions. After the answers have been entered for each student, store the result of the students score in a dictionary. The key of the dictionary should be the student ID and the number of correct answers the value.

Using the dictionary created, display the result for all students indicating if they passed or failed. A student must correctly answer 8 out of 10 questions to pass the exam. Your script should also display the percentage of students who passed the test in a given day.

Input validation

  • Make sure the user enters a valid option for answer (A, B, C or D). Answers are not case sensitive. Thus, it does not matter if a student choses "A" or a as a correct answer.
  • Each student has a unique ID

NB: Do not prompt the user for number of students.

Sample Report for 6 students

ID Correct Wrong Pass/Fail
2 8 2 Pass
1 9 1 Pass
5 6 4 Fail
4 7 3 Fail
8 8 2 Pass
6 10 0 Pass

66.7% of students passed the test

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.