Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please I need help with this turtle lab assignment in Python Language! I will be very grateful!! Drawing the square involves the forward), right() and

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Please I need help with this turtle lab assignment in Python Language! I will be very grateful!!

Drawing the square involves the forward), right() and left() methods. Drawing the triangle also utilizes these same methods but requires more trial and error to determine the angles of the lines. Follow theses steps to draw your shapes 1 Open up IDLE and open a new window. Save this file as DrawingShapes py 2. At the top of your new window, type in import turtle. This statement imports the turtle library or class. 3. We will work on the circle first. As mentioned in the description above, we will allow the user to determine the pen size, color and ill. For the pen size, we will only allow the user to determine this once so that it is applicable to all three shapes. Additionally we will limit the pen color to red, blue or yellow. Depending upon which of these colors they choose it will determine the fill color. If the user chooses the color red, fill the circle with yellow. If the user chooses the blue pen color fill the circle with red. Finally if the user chooses yellow, then fill the circle with green. Therefore, we will need to create some variables. Underneath the import turtle option, type in #variables pen_color = str() fill_color = str() pen_size = int() 4. Next we need to move the pen so our circle starts at the top of the screen. Since we don't want the turtle drawing while we are moving we will use the penup() and then pendown() methods. Finally to move the turtle to a specifc part of the screen, we will use the goto() method. The first argument when we use this method is the horizontal position. The second argument is the vertical position. So, turtle.goto(0,0) is the center of the screen. Type in the following code: #Moving the pen turtle. penup() turtle.goto (0, 150) turtle. pendown() del Page 2 of 0 - 200 5. Type in two input statements that allow the user to determine the pen size and pen color The pen size can be any integer from 1 to 10. The pen color needs to be red, blue or yellow. 6. Now create a decision structure to determine the fill color 7. Type in the following cod eo set the pen size, pen color and fill color turtle. pensize (pen_size) turtle.pencolor (pen_color) turtle.fillcolor (fill_color) 8. To begin drawing the circle we need to turn on the fill color. As soon as we are done filling our color we need to turn it off. Type in the following code: File Edit Format Run Options Window Help turtle.begin fill() #drat circle turtle.circle (50) #stopping the fill turtle.end fill() 9. Run your code. You will be prompted for a pen size and a pen color. For my test entered 3 for the pen size and red for the pen color. Below is what should print to your screen 10. Now we move on to the square Using the code listed in #4 above about moving the pen as a starting point, put the pen up, move turtle to the left 90 degress, move turtle forward 150 pixels and put the pon down. This should move you to the position to start drawing the square 11. Next ask the user for another pen color and set the turtle's pen color to that new color 12 Using the decision structure you wrote above, copy and paste it below so you can determine the fill color 13. Change the fill color for the turtle and begin fill 14. Type in the following code ho 15. Stop filling and test 16. I selected 3 as the pen size and red for my circle. I selected blue for my square. Your shapes should look like this so far: 17. On to our last shape, the Triangle. We need to move the pen one last time. Using the moving pen code listed above, put the turtle's pen up, move it left 90 degrees, move it forward 150 pixels and then put the pen down. 18. As with the square, you need to ask the user for another pen color and determine the fill color Copy and paste your working code that does that 19 Begin filling by typing in the turtle's begin fill method 20. Drawing a triangle is tricky due to the angles of the tums. Here is the code that will draw a triangle #drawing the triangle turtle.right (35) turtle. forward (125) turtle.right (235) turtle. forward (150) turtle.left (127) turtle. forward (130) 21. Add code to stop the fill. 22. Run your code to test. When using 3 as the pen size. red for the circle, blue for the square and green for the triangle, my output looked like the following On Your Own In this section of the lab you will create code that will draw either a square or a circle in a particular location on the screen. Those locations are Top Left Top Right Bottom Left and Bottom Right. The user will determine the shape as well as the pen color and fill. Based on these decisions your code will need to do the following Top Left Location: the pen size must be 3 Top Right Location: the pen size must be 5 Bottom Left Location: the pen size must be 7 Bottom Right Location: the pen size must be 9 Circles: When the user selects a circle the program needs to ask the user for the pen color The choices are red, blue or yellow. All of the pen colors will determine a specific fill color Explore online to find a new fill color Squares. When the user selects a square the program needs to ask the user for a fill color. The choices are red, blue or yellow. These colors will determine the pen color Pick a different color. Farbala with the location allow.diabeck out the section of your bookin.chanel Drawing the square involves the forward), right() and left() methods. Drawing the triangle also utilizes these same methods but requires more trial and error to determine the angles of the lines. Follow theses steps to draw your shapes 1 Open up IDLE and open a new window. Save this file as DrawingShapes py 2. At the top of your new window, type in import turtle. This statement imports the turtle library or class. 3. We will work on the circle first. As mentioned in the description above, we will allow the user to determine the pen size, color and ill. For the pen size, we will only allow the user to determine this once so that it is applicable to all three shapes. Additionally we will limit the pen color to red, blue or yellow. Depending upon which of these colors they choose it will determine the fill color. If the user chooses the color red, fill the circle with yellow. If the user chooses the blue pen color fill the circle with red. Finally if the user chooses yellow, then fill the circle with green. Therefore, we will need to create some variables. Underneath the import turtle option, type in #variables pen_color = str() fill_color = str() pen_size = int() 4. Next we need to move the pen so our circle starts at the top of the screen. Since we don't want the turtle drawing while we are moving we will use the penup() and then pendown() methods. Finally to move the turtle to a specifc part of the screen, we will use the goto() method. The first argument when we use this method is the horizontal position. The second argument is the vertical position. So, turtle.goto(0,0) is the center of the screen. Type in the following code: #Moving the pen turtle. penup() turtle.goto (0, 150) turtle. pendown() del Page 2 of 0 - 200 5. Type in two input statements that allow the user to determine the pen size and pen color The pen size can be any integer from 1 to 10. The pen color needs to be red, blue or yellow. 6. Now create a decision structure to determine the fill color 7. Type in the following cod eo set the pen size, pen color and fill color turtle. pensize (pen_size) turtle.pencolor (pen_color) turtle.fillcolor (fill_color) 8. To begin drawing the circle we need to turn on the fill color. As soon as we are done filling our color we need to turn it off. Type in the following code: File Edit Format Run Options Window Help turtle.begin fill() #drat circle turtle.circle (50) #stopping the fill turtle.end fill() 9. Run your code. You will be prompted for a pen size and a pen color. For my test entered 3 for the pen size and red for the pen color. Below is what should print to your screen 10. Now we move on to the square Using the code listed in #4 above about moving the pen as a starting point, put the pen up, move turtle to the left 90 degress, move turtle forward 150 pixels and put the pon down. This should move you to the position to start drawing the square 11. Next ask the user for another pen color and set the turtle's pen color to that new color 12 Using the decision structure you wrote above, copy and paste it below so you can determine the fill color 13. Change the fill color for the turtle and begin fill 14. Type in the following code ho 15. Stop filling and test 16. I selected 3 as the pen size and red for my circle. I selected blue for my square. Your shapes should look like this so far: 17. On to our last shape, the Triangle. We need to move the pen one last time. Using the moving pen code listed above, put the turtle's pen up, move it left 90 degrees, move it forward 150 pixels and then put the pen down. 18. As with the square, you need to ask the user for another pen color and determine the fill color Copy and paste your working code that does that 19 Begin filling by typing in the turtle's begin fill method 20. Drawing a triangle is tricky due to the angles of the tums. Here is the code that will draw a triangle #drawing the triangle turtle.right (35) turtle. forward (125) turtle.right (235) turtle. forward (150) turtle.left (127) turtle. forward (130) 21. Add code to stop the fill. 22. Run your code to test. When using 3 as the pen size. red for the circle, blue for the square and green for the triangle, my output looked like the following On Your Own In this section of the lab you will create code that will draw either a square or a circle in a particular location on the screen. Those locations are Top Left Top Right Bottom Left and Bottom Right. The user will determine the shape as well as the pen color and fill. Based on these decisions your code will need to do the following Top Left Location: the pen size must be 3 Top Right Location: the pen size must be 5 Bottom Left Location: the pen size must be 7 Bottom Right Location: the pen size must be 9 Circles: When the user selects a circle the program needs to ask the user for the pen color The choices are red, blue or yellow. All of the pen colors will determine a specific fill color Explore online to find a new fill color Squares. When the user selects a square the program needs to ask the user for a fill color. The choices are red, blue or yellow. These colors will determine the pen color Pick a different color. Farbala with the location allow.diabeck out the section of your bookin.chanel

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions