I’m working on a Python exercise and need support.
Studying Nested Loops
This lab involves studying and explaining how nested loops work, both based on iteration loops and index-based loops.
Using lab zip folder
Download the zip folder for lab 8 Unzip it and study the code in lab8.py. Because colors is already defined for you, you may test out both functions using colors as an argument.
I ALL READY ATTACHED THE ZIP FILE WITH THIS QUESTION TAHNK YOU .
For the following, either answer the question or provide the requested code:
- color_match returns a list of pairs. How is each pair represented?
- If color_match is given a list of 9 colors, how many pairs does it produce? Show how you can calculate the answer.
- Write a modification of color_match and call it color_display so that it does the following:
- Omits pairs that have the same color. For example, green green will no longer be a pair in the list.
- Instead of returning the list, color_display prints each pair by hyphenating the pair. For example, green yellow will be printed as green-yellow.
- If color_display is given a list of 9 colors, how many pairs does it produce? Can you provide a general way of calculating that number?
- Note that color_blend uses index-based loops. Does it show blue-green and green-blue? Given the list of colors, can you always predict the order that the colors in a color pair will appear (e.g. will it be green-blue or blue-green).
- Can you predict how many unique pairs are produced from a list of 9? Do you have a general process for calculating that?
- Write a function called exotic_fruits that takes two parameters: a list of colors (represented as strings, e.g. the colors variable) and a list of fruits (represented as string, e.g. the fruits variable). The function should return a list of all possible exotic fruits that combine a color with a fruit (e.g. “blue melon”).
- If exotic_fruits is given x colors and y fruits, how many exotic fruits does it produce?
ALSO SEND THE EXAMPLE FOR LAB 4 IT SHOULD LOOKS LIKE THAT.