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
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