Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################################################
- # Name: Anisha Asad
- # Class: CIS-1400
- # Assignment: Homework 8 Fall 2019
- # File: Homeowork_8.py
- # Purpose: Driver's License Test w/ Arrays
- #######################################################
- def main():
- print('\n** Anisha Asad **\n') # Display author's name
- # Correct answers
- answers = ["B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B",
- "C", "D", "A", "D", "C", "C", "B", "D", "A"]
- # List that holds the incorrect question numbers and also the list that holds the user response
- incorrect, response = [], []
- # Counter variables to hold our incorrect and correct answer count
- correct_num, incorrect_num = 0, 0
- # Runs 20 times for 20 questions
- for i in range(0, 20):
- # User input
- a = input(f"What is the answer for question {i+1}: ")
- # Add the response to the list as a capital letter
- response.append(a.upper())
- # Check to see if the answer is right
- if a.upper() == answers[i]:
- correct_num += 1
- else:
- incorrect_num += 1
- # Append the question number to the list of incorrect ones
- incorrect.append(i+1)
- if correct_num >= 15:
- print("Passed")
- else:
- print("Not Passed")
- # Print the correct and incorrect number of questions
- print(f"Total correct:{correct_num}")
- print(f"Total incorrrect:{incorrect_num}")
- print("The following questions were incorrect...")
- print(incorrect)
- # Call main
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement