Question: Define a function named getRectangles with a single parameter: The parameter, called shapeList in this description, is a list of strings of the types created

Define a function named getRectangles with a single parameter: The parameter, called shapeList in this description, is a list of strings of the types created in Milestone 1 functions The function should return a list of dictionaries. The input list is a list of string of the types created in Milestone 1. The function looks through that list and identifies each string that starts with the word rectangle. Each rectangle entry is converted into a dictionary with the following key/value pairs: 'color': a list containing the integers red, green, and blue color channels 'x1': integer for corner 1 x coordinate 'y1': integer for corner 1 y coordinate 'x2': integer for corner 2 x coordinate 'y2': integer for corner 2 y coordinate 'depth': integer for depth All of the dictionaries are added into a single list in the order they appeared in the input list and returned. Test Cases: getRectangles([]) should evaluate to [] getRectangles(['rectangle 255000010201']) should evaluate to [{'color': [255,0,0],'x1': 0,'y1': 0,'x2': 10,'y2': 20, 'depth': 1}] getRectangles(['rectangle 255000010201', 'circle 02550-10-401020', 'rectangle 02550-10-4010202']) should evaluate to [{'color': [255,0,0],'x1': 0,'y1': 0,'x2': 10,'y2': 20, 'depth': 1},{'color': [0,255,0],'x1': -10,'y1': -40,'x2': 10,'y2': 20, 'depth': 2}]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!