Question: Suppose there are two non-empty list variables of equal length in Python called coords and sides. The variable coords contains sub-lists of size 2, with

Suppose there are two non-empty list variables of equal length in Python called coords and sides.

The variable coords contains sub-lists of size 2, with each of these values representing an x and a y co-ordinate.

The variable sides also contains sub-lists of size 2, with each of these values representing firstly the length then the width of a rectangle.

Also assume there is also a function in Python called draw_rectangle which takes as its parameters two integers representing firstly the length then the width of a rectangle. The function then draws that rectangle using Turtle graphics functions.

Complete the following code to draw each of the rectangles represented by the length-width pairs in the list sides at the x-y co-ordinates contained at the same index in the list coords.

for Term 1 goto(coords[index])draw_rectangle(sides[index][0], sides[index][1])pair in sidesfor xy in coords:goto(coords[pair])goto(xy)draw_rectangle()draw_rectangle(sides[0][index], sides[1][index])draw_rectangle(sides[0][0], sides[0][1])draw_rectangle(sides[0], sides[1])index in range(len(sides))draw_rectangle(sides[index][index + 1], sides[index][index + 1]): penup() Term 2 goto(coords[index])draw_rectangle(sides[index][0], sides[index][1])pair in sidesfor xy in coords:goto(coords[pair])goto(xy)draw_rectangle()draw_rectangle(sides[0][index], sides[1][index])draw_rectangle(sides[0][0], sides[0][1])draw_rectangle(sides[0], sides[1])index in range(len(sides))draw_rectangle(sides[index][index + 1], sides[index][index + 1]) pendown() Term 3 goto(coords[index])draw_rectangle(sides[index][0], sides[index][1])pair in sidesfor xy in coords:goto(coords[pair])goto(xy)draw_rectangle()draw_rectangle(sides[0][index], sides[1][index])draw_rectangle(sides[0][0], sides[0][1])draw_rectangle(sides[0], sides[1])index in range(len(sides))draw_rectangle(sides[index][index + 1], sides[index][index + 1])

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 Databases Questions!