Question: USE PYTHON PLEASE For this question, you will write two programs that determine if a car should go through an intersection or stop. Your program
USE PYTHON PLEASE
For this question, you will write two programs that determine 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). The following rules should govern the car's decision: "Go" when the light is "green" When the light is "yellow", "Go" if the car can reach the intersection within 5 seconds. Otherwise, the car must "Stop' When the light is "red", "Go" if the car can reach the intersection in 2 seconds Otherwise, the car must "Stop" If the light is any color other than "green", "red", or "yellow", the car must "Stop" Write a program that prints out the proper command (Go" or "Stop") based on the given inputs using only nested if and else statements (i.e., do not use elif, and, or, not, etc.). For example, your program should have a structure similar to: if Boolean_ statement 1: if Boolean_ statement 2 #code block 2a else: #code block 2b else: if boolean statement 3: #code block 3a else: #code block 3b Write a program that prints out the proper command (Go" or "Stop") based on the given inputs using a single if/else statement with compound Boolean expressions. In this case, your program must have a structure like: if compound_ Boolean_ statement: #code block 1 else: #code block 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
