Write a simple program that tests your extrasensory perception! The program randomly selects a color from the following list of words: Red, Green, Blue, Orange, and Yellow. To select a word, the program could generate a random number. For example, if the number is 0, the selected word is Red; if the number is 1, the selected word is Green; and so forth.

Respuesta :

Answer:

The program in Python is as follows:

from random import randrange

colors = ['Red', 'Green', 'Blue', 'Orange', 'Yellow']

randNum = randrange(5)

print(colors[randNum])

Explanation:

This imports the randrange module from the random library

from random import randrange

This initializes the list of colors

colors = ['Red', 'Green', 'Blue', 'Orange', 'Yellow']

This generates a random number between 0 and 4 (inclusive)

randNum = randrange(5)

This prints the corresponding color

print(colors[randNum])