Join the IDNLearn.com community and start exploring a world of knowledge today. Our platform offers reliable and comprehensive answers to help you make informed decisions quickly and easily.
The program illustrates the use of conditional statements
Conditional statements are statements used to make comparison and decisions
The program written in Python, where comments are used to explain each action is as follows:
#This gets input for the color
color = input("Color: ").lower()
#This checks if the input is red
if color == "red":
print(“Red light: you should stop.”)
#This checks if the input is yellow
elif color == "yellow":
print(“Yellow light: you should get ready.”)
#This checks if the input is green
elif color == "green":
print(“Green light: you should go.”)
#This checks for invalid input
else:
print(“Invalid")
Read more about Python programs at:
https://brainly.com/question/24833629