Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 5) Define a new function called randomColor() to select and return one of five colors. Put this function above problemFive(), not inside problemFive().

Python 3

image text in transcribed

5) Define a new function called randomColor() to select and return one of five colors. Put this function above problemFive(), not inside problemFive(). a) Import the random module, place the import at the top of your file. The randomColor() function should use the random.choice() function. You can search for this to see an example online b) In the randomColor() function create a variable colors and assign the following list: ['red', 'white', 'blue', 'green', 'orange', 'pink'] c) In the randomColor() function, use the random.choice() function with the colors variable to pick a random color and assign it to a variable color d) Return the selected color from the randomColor() function e) In your problemFive() function, call the randomColor() function inside a for loop. Have the body of the for loop call the randomColor() function five (5) times. You can use [1,2,3,4,5] or range() with this for loop. Print the returned color from each call to the randomColor() function, one per line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

d. A toll charge required for driving on a public highway.

Answered: 1 week ago

Question

What part of what I said was useful? And how?

Answered: 1 week ago

Question

What are the weaknesses of each one?

Answered: 1 week ago

Question

What are the consequences of each one?

Answered: 1 week ago

Question

How can you be sure that it does not meet the criteria?

Answered: 1 week ago