Question: Problem 4 For this question, you will write a program called drive.py that determines if a car should go through an intersection or stop. Your

Problem 4

For this question, you will write a program called drive.py that determines if a car should go through an intersection or stop. Your program will prompt the user for the colour of the traffic light at the intersection (a string), the distance to the intersection in meters (a float), and the speed of the car in meters per second (a float). Your program must then determine if the car should go through the intersection or stop.

The following rules should govern the cars decision:

1. Go when the light is green

2. When the light is yellow, Go if the car will reach the intersection within 5 seconds. Otherwise, the car must Stop

3. When the light is red, Go if the car will reach the intersection in 2 seconds. Otherwise, the car must Stop

4. If the light is any color other than green, red, or yellow, the car must Stop

Hint: you can use the programming example done is class as the starting point.

use python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!