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
JavaScript Write a function named "reverse_kvs" that has a key-value store as a parameter and returns...
JavaScript Write a function named "reverse_kvs" that has a key-value store as a parameter and returns a new key-value store. Your function should add each key-value pair in the parameter to the new key-value store EXCEPT reversing the key and value. For example, if the key-value "extreme":45 were in the parameter then the returned key-value store should contain the key-value pair 45:"extreme". Code: function reverse_kvs(store) { var reverse_store = {}; for (var key in store) { if (store.hasOwnProperty(key)) { reverse_store[store[key]]...
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 function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t...
Write a function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t y = v*cos(A)*t -.5*(9.8)*t**2 Loop through t starting at 0 and increment by .1 until y<=0. (hint, while loop) Experiment with values of velocity V (1 to 20) and angle A (0 to 90) that gives you a good plot that does not go off the screen. Position the start of the plot at the left bottom of the screen
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...
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!
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT