Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #######################################################
  2. # Name: Anisha Asad
  3. # Class: CIS-1400
  4. # Assignment: Homework 8 Fall 2019
  5. # File: Homeowork_8.py
  6. # Purpose: Driver's License Test w/ Arrays
  7. #######################################################
  8.  
  9. def main():
  10.  
  11. print('\n** Anisha Asad **\n') # Display author's name
  12.  
  13. # Correct answers
  14. answers = ["B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B",
  15. "C", "D", "A", "D", "C", "C", "B", "D", "A"]
  16. # List that holds the incorrect question numbers and also the list that holds the user response
  17. incorrect, response = [], []
  18. # Counter variables to hold our incorrect and correct answer count
  19. correct_num, incorrect_num = 0, 0
  20.  
  21. # Runs 20 times for 20 questions
  22. for i in range(0, 20):
  23. # User input
  24. a = input(f"What is the answer for question {i+1}: ")
  25. # Add the response to the list as a capital letter
  26. response.append(a.upper())
  27. # Check to see if the answer is right
  28. if a.upper() == answers[i]:
  29. correct_num += 1
  30. else:
  31. incorrect_num += 1
  32. # Append the question number to the list of incorrect ones
  33. incorrect.append(i+1)
  34.  
  35. if correct_num >= 15:
  36. print("Passed")
  37. else:
  38. print("Not Passed")
  39.  
  40. # Print the correct and incorrect number of questions
  41. print(f"Total correct:{correct_num}")
  42. print(f"Total incorrrect:{incorrect_num}")
  43. print("The following questions were incorrect...")
  44. print(incorrect)
  45.  
  46. # Call main
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement