Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer must be in Python 3 Answer: import turtle def rectangle(t, shortSide): t.down() for i in range(2): t.fd(shortSide) t.rt(90) t.fd(shortSide*2) t.rt(90) def adjacentRectangles(t, number, ishortSide):

image text in transcribed

Answer must be in Python 3

Answer:

import turtle

def rectangle(t, shortSide): t.down() for i in range(2): t.fd(shortSide) t.rt(90) t.fd(shortSide*2) t.rt(90)

def adjacentRectangles(t, number, ishortSide):

for i in range(number): rectangle(t, ishortSide) t.up() t.fd(ishortSide) ishortSide *= 2

s = turtle.Screen() t = turtle.Turtle() size = 10 numSides = 5 adjacentRectangles(t, numSides, size)

Question 11A Write a function named rectangle() that uses turtle graphics to draw a rectangle. The function rectangle() takes two parameters i. t, a turtle that is used to draw and ii. shortSide, the length of a short side of the rectangle The ratio of the length of a short side to a long side is 1:2. The function rectangle() should draw a short side first. (Hint 1: the turtle must be down to draw.) It should leave the turtle at the same location and with the same orientation it had initially.(Hint 2: the turtle may initially be at any location on the screen and in any orientation.) For full credit, you must use a loop to perform the repeated operations. Question 11B Write a function named adjacentRectangles() that draws a series of rectangles next to each other. Each rectangle is double the size of the preceding one. The function adjacentRectangles) takes three parameters: i. t, a turtle that is used to draw and ii. ishortSide, the length of the short side of a rectangle, and ii. number, the number of rectangles to draw The function adjacentRectangles() should call the function rectangle() that you coded in 11A to draw each rectangle For example, suppose that adjacentRectangles() is called by the following code import turtle s-turtle.Screen () tturtle.Turtle() size - 10 numSides 5 adjacentRectangles (t, numSides, size) Then this would be correct graphical output

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

More Books

Students also viewed these Databases questions

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago