Write a function named cup that uses a turtle parameter t to draw a cup consisti
ID: 3863813 • Letter: W
Question
Write a function named cup that uses a turtle parameter t to draw a cup consisting of three sides of a square. Your function should not change the position or orientation of t before drawing the first side of the cup.
The turtle t that is passed to cup may initially be either up or down and may be at any location on the screen and in any orientation.
After drawing a side, the turtle t should turn left. When the function cup returns, t should
be in the initial position and orientation.
For full credit, the repeated operations should be performed in a loop.
The function cup takes two parameters
t, a turtle that is used for drawing sideLength, the length of a side of the cup
The figure at the right shows sample graphical output of cup.
Question 11b (10 points)
Write a function named cups that calls the function cup repeatedly to draw a set of measuring cups of increasing size.
The function cups takes four parameters:
t, a turtle used for drawing initial, the length of a side of the first cup incr, the increase in side length of each successive cup reps, the number of cups to draw
For example, the graphical output of the code below should look like the illustration at the right:
import turtle
s = turtle.Screen()
t = turtle.Turtle()
cups(t, 50, 30, 4) (Answer using Python)
Explanation / Answer
Write a function named cup that uses a turtle parameter t to draw a cup consisting of three sides of a square. Your function should not change the position or orientation of t before drawing the first side of the cup.
The turtle t that is passed to cup may initially be either up or down and may be at any location on the screen and in any orientation.
After drawing a side, the turtle t should turn left. When the function cup returns, t should
be in the initial position and orientation.
For full credit, the repeated operations should be performed in a loop.
The function cup takes two parameters
t, a turtle that is used for drawing sideLength, the length of a side of the cup
The figure at the right shows sample graphical output of cup.
Question 11b (10 points)
Write a function named cups that calls the function cup repeatedly to draw a set of measuring cups of increasing size.
The function cups takes four parameters:
t, a turtle used for drawing initial, the length of a side of the first cup incr, the increase in side length of each successive cup reps, the number of cups to draw
For example, the graphical output of the code below should look like the illustration at the right:
import turtle
s = turtle.Screen()
t = turtle.Turtle()
cups(t, 50, 30, 4)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.