Write a function named rectangle() that uses turtle graphics to draw a rectangle
ID: 3583144 • Letter: W
Question
Write a function named rectangle() that uses turtle graphics to draw a rectangle. The function rectangle() takes two parameters: t. a turtle that is used to draw and short Side, 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. It should leave the turtle at the same location and with the same orientation it had initially. For full credit, you must use a loop to perform the repeated operations. Write a function named adjacent Rectangles() 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: t. a turtle that is used to draw and ishortSide, the length of the short side of a rectangle, and 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: inport turtle s = turtle.Screen() t = turtle.Turtle() size = 10 numSides = 5 adjacentRectangles(t, nunSides, size) Then this would be correct graphical output.Explanation / Answer
#Problem 1 def wordPositions (s, ret): for word in s: size = len(s) stringDic = {key:value} stringDic[key] = s[0] #stringDic[] #.......... #.................... #........................... s ='Donuts are Donuts to Chocolate for Chocolate to ME.' print(wordPositions(s, stringDic) #Problem 2A def rectangle (t, shortSide): import turtle s = turtle.Screen() t = turtle.Turtle() for i in range (5): t.pendown() t.fd(100) t.right(90) t.fd(shortSide) t.right(90) t.fd(100) t.right(90) t.fd(100) t.right(90) t.penup() print(rectangle, t, 25) #Problem 2B def adjancetRectangles(t, ishortSide, number): import turtle s = turtle.Screen() t = turtle.Turtle() for i in range (number): print(adjacentRectangles, t, 25) print(rectangle, t, ishortside)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.