Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What differentiates you from your competitors?

Answered: 1 week ago

Question

You are to meet him on friday at the un building in nyc.

Answered: 1 week ago