Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started