Question: ( a ) Write a python program that simulates a traffic light. The program should consist of the following: ( 5 ) i . A

(a) Write a python program that simulates a traffic light. The program should consist of the following:
(5)
i. A user defined function trafficLight () that accepts input from the user, displays an error message if the user enters anything other than RED, YELLOW, and GRFEN. Function light () is called and following is displayed depending upon return value from light .
"STOP, your life is precious" if the value returned by light( is 0.
-"Please WAIT, till the light is Green "if the value retumed by light O is I
-"GO! Thank you for being patient" if the value returned by lighto is 2.
ii. A user defined function light that accepts a string as input and returns 0 when the input is RED, 1 when the input is YELLOW and 2 when the input is GRFEN. The input should be passed as an argument.
iii. Display " SPEED THRII LS BUT KIL LS" after the function trafficl ight() is executed.
 (a) Write a python program that simulates a traffic light. The

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!