Question

In: Computer Science

Write a function named cup that uses a turtle parameter t to draw a cup consisting...

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)

Solutions

Expert Solution

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 Solutions

Write a function that draw your initials. (Using python 3 turtle) (T, S)
Write a function that draw your initials. (Using python 3 turtle) (T, S)
Write a function named "characters" that takes a string as a parameter and returns the number...
Write a function named "characters" that takes a string as a parameter and returns the number of characters in the input string
C++ A void function named NextLeapYear() that takes an int reference parameter. If the parameter is...
C++ A void function named NextLeapYear() that takes an int reference parameter. If the parameter is positive, the function will assign it the next leap year after it; otherwise, the function will assign 4 to it.
Declare and define a function named getCurrentHours_OR_Month that accepts one Boolean parameter. If the Boolean parameter...
Declare and define a function named getCurrentHours_OR_Month that accepts one Boolean parameter. If the Boolean parameter is true, the function returns current hours; if the Boolean parameter is false, the function returns current month. o This function will obtain the current system time and extract the hours or the month value from the system time depending on the Boolean being received. o This function will return the extracted value as an integer value. o Note that the system time displays...
Create a function named ‘dividing’. This function will take one parameter value, which will be an...
Create a function named ‘dividing’. This function will take one parameter value, which will be an integer. For the function you will use ‘Exception Handling’ with the use of the try and except statements to try and return the results of a number divided by the parameter value given to the function. If the parameter passed to the function is the integer value of zero then your function should return ‘You tried to divide by zero!’ through the use of...
Write a RECURSIVE method that receives as a parameter an integer named n. The method will...
Write a RECURSIVE method that receives as a parameter an integer named n. The method will output n # of lines of stars. For example, the first line will have one star, the second line will have two stars, and so on. The line number n will have "n" number of ****** (stars) so if n is 3 it would print * ** *** The method must not have any loops!
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and...
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and returns "true" if all the characters included in the string are ordered in ascending order of their ASCII codes or the input string is a null string, and returns "false" otherwise. For example, if the string "ABXab" is passed to the function, it returns "true" because the ASCII code of 'B' is greater than 'A', 'X' is greater than 'B', 'a' is greater than...
In java Write a static method named consecutiveDigits that accepts an integer n as a parameter...
In java Write a static method named consecutiveDigits that accepts an integer n as a parameter and that returns the highest number of consecutive digits in a row from n that have the same value. For example, the number 3777785 has four consecutive occurrences of the number 7 in a row, so the call consecutiveDigits(3777785) should return 4. For many numbers the answer will be 1 because they don't have any adjacent digits that match. Below are sample calls on...
Write a Racket function that will take a list of numbers as a parameter and return...
Write a Racket function that will take a list of numbers as a parameter and return true if they all are positive, and false otherwise. You are NOT required to check the type of elements in the list. (please do on racket language)
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the...
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the #file and return the contents.# # # - If the contents of the file can be interpreted as # an integer, return the contents as an integer. # - Otherwise, if the contents of the file can be # interpreted as a float, return the contents as a # float. # - Otherwise, return the contents of the file as a # string. #...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT