Question
Question 3 Use IDLE Editor to create a file called cis122-assign03-turtle.py . Remember to add the docstring at the top of the file with your
Question 3
Use IDLE Editor to create a file called cis122-assign03-turtle.py. Remember to add the docstring at the top of the file with your name and information about the assignment.
Also, use function docstrings for all functions.
Note that this question has a number of lettered steps.
A. Create a void function to draw a line using Python's Turtle graphics. Your function must have the following interface:
draw_line(t, x, y, angle, length)
Additionally, your draw_line() function must:
- Use setx() and sety() Turtle methods to set the line starting location
- Use seth() Turtle method to set the line heading
- Use pu() and pd() Turtle methods to pickup and put down the drawing pen
- Use fd() Turtle method to draw the line
- End the method with the Turtle pen in the up position
Refer to the Python Software Foundation's Turtle Graphics (Links to an external site.) web page for information on all of these Turtle Graphics methods.
B. Test your line drawing function using the following values for a series of test runs calling the function.
X | Y | Angle | Length |
100 | 100 | 0 | 200 |
-100 | -100 | 270 | 50 |
200 | -200 | 45 | 75 |
C. After conducting the test runs, use single line comment to comment out all three of the test runs.
D. Add a docstring comment immediately after the function. This function has a more extensive docstring.
def draw_line(t, x, y, angle, length): """One line summary of your function An extended summary of your function, including any final state (such as whether or not the pen is left up or down) Args:e.g. t (Turtle): Drawing Turtle x (int/float): starting x location Returns: None """
E. Add another void function that will draw a series of radial lines with the following interface:
draw_radial_lines(t, x, y, length, num_lines)
Additionally, your draw_radial_lines must:
- Use a for loop to draw each radial line by calling your draw_line() function
- Include a docstring similar to the draw_line() function
Test your draw radial line function with the following test data:
X | Y | Length | Num_Lines |
-100 | -100 | 25 | 8 |
-100 | 100 | 100 | 4 |
100 | -100 | 200 | 16 |
100 | 100 | 50 | 32 |
F. After conducting the test runs, use single line comment to comment out all four of the test runs.
G. Create a final void function that will draw the same radial in all four quadrants with the following interface:
draw_radials_in_quadrants(t, length, num_lines)
By quadrants we mean writing to the same x and y location but the in each of the four quadrants where x and y would have the following signs:
- Quadrant 1: +, +
- Quadrant 2: -, +
- Quadrant 3: -, -
- Quadrant 4: +, -
Additionally, your draw_radials_in_quadrants() function must:
- Separate each radial in each quadrant from other quadrants using twice the length
- Include a docstring
Test your radial quadrant drawing function using the following test data:
Length | Num_Lines |
75 | 8 |
50 | 16 |
Below is an example of the desired output.
photo of radial line circles
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started