Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- # List of questions asked by the computer, you can add your own, but you need to change the answers in that case.
- questions = [
- "Rainfall detected. Should you change your speed? [87 km/h]",
- "Identified 'Sharp Turns' sign. Should you change your speed? [103 km/h]",
- "The vehicle in front suddenly brakes. Collision is imminent. What should you do?",
- "Identified 'bicycle' ahead [8 km/h]. What should you do?",
- "Fuel level is less than 1/3. Should you change your route?",
- "Collision detected on the route, 10 km ahead. Should you change your route?",
- ]
- # List of answers in the order of questions asked, you can add your own.
- answers = [
- ["1) Increase speed", "2) Reduce speed", "3) Maintain current speed"],
- ["1) Increase speed", "2) Reduce speed", "3) Maintain current speed"],
- ["1) Change lanes to the left", "2) Move to the shoulder", "3) Brake without changing lanes"],
- ["1) Change lanes to the left", "2) Overtake and return to the right lane", "3) No, continue straight"],
- ["1) Look for a gas station within 30 km", "2) Look for a gas station within 50 km", "3) Keep driving"],
- ["1) Look for the shortest alternative", "2) Look for the fastest alternative", "3) No, keep driving"],
- ]
- # Function to display a statistics report of given answers
- def review_report():
- print("\n*** Report of Given Answers ***")
- # Loop to calculate statistics for each question
- for i in range(len(questions)):
- print(questions[i])
- answered = given_answers[i]
- total_answers = sum(answered)
- if total_answers == 0:
- print("\t -> Question not asked!")
- continue
- # Calculate the percentage for each answer
- for j in range(len(answers[i])):
- percentage_value = 100 * (given_answers[i][j] / total_answers)
- print(f"\t-> {round(percentage_value)}% {answers[i][j]}")
- # Function to ask questions to the user
- def provide_answers():
- print("\n*** Provide Answers ***")
- # Copy questions to a new list in random order
- random_questions = []
- for i in range(len(questions)):
- random_questions.append(i)
- random.shuffle(random_questions)
- # Loop to display questions and answers
- ## 3 - HERE, WE CREATE CODE TO ASK QUESTIONS ##
- # Initialize the list and variable here
- given_answers = []
- choise = -1
- # Menu handling
- while choise != 0:
- # Display menu options
- print("\n*** What to do? ***")
- print("1. Review Report")
- print("2. Provide Answers")
- print("0. Exit")
- # Get user input here
- ## 2 - HERE, CREATE CODE TO RESPOND TO USER'S CHOICE ##
- break
Add Comment
Please, Sign In to add comment