12.3k views
5 votes
Write a program to output the signal status based on the signal colour taken as input.

SIGNAL COLOR SIGNAL STATUS
RED STOP
YELLOW WAIT
GREEN GO

2 Answers

3 votes
What subject is this
User Adam Johnston
by
5.6k points
2 votes

Answer:

colour = "YELLOW"

signalMap = {

"RED" : "STOP",

"YELLOW" : "WAIT",

"GREEN" : "GO"

}

print(colour + " means " + signalMap[colour])

Step-by-step explanation:

Since python doesn't have switch statements, this map is a useful alternative.

User LynxZh
by
4.8k points