Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description You will be making a program to move Randy the Turtle around and draw a square. The interesting thing about Randy is that he

image text in transcribed
image text in transcribed
image text in transcribed
Description You will be making a program to move Randy the Turtle around and draw a square. The interesting thing about Randy is that he likes to make the square a random size. The random library will help us out with that. Then he'll draw another square. Your task is to: Make Randy move forward a random amount of distance, between 10 and 150 units. Make Randy turn to the left 90 degrees, and move the same amount of distance Make Randy turn 90 degrees left again, move again, etc until he draws a square. We will give you code that will have Randy pick his pen up and move away from the first square and be ready to draw a second square. You will then insert the code to make him draw the second square Notice that unless you set the random seed, each time you run your code, Randy makes different sized squares, and the second one is in a different position. Since this lab won't be auto graded, we don't need to worry about repeating the same set of random numbers like we did in the dice program. So it's fine (and more interesting) to just leave the random.seed() function commented out. IMPORTANT! Do NOT name your file "turtle.py". If you do, you will wipe out the Python turtle package and may damage your entire Anaconda install. While normally you want to give your files descriptive names, you definitely want to avoid name clashes with pre-existing Python packages. A good name might be 'draw_squares.py" or something similar, since later you may also be using the turtle package to draw something Note 1: Running this program in zyBooks does not work. You must run it in Spyder to make it function. When you run the program from Spyder, it creates a window that Randy draws in. In order to run the program a second time (so you can see the different sized squares), you need to close that window. Note 2: Even though you must develop and run your program in Spyder, it MUST submitted for grading in zyBooks before the deadline. You will get a score of 0 from zyBooks; do not be alarmed, the TAS will hand grade your submission from zyBooks. However, if you submit multiple times, make sure that your best submission is your LAST submission, so that the TAS will know which one to grade. The objective of this lab is to practice using function calls for a fun result. There are no automated test cases for this lab, your TA will grade it. Feel free to play around with other turtle functions and draw other things. LAB 16.11.1: Lab 5C: Randy the Turtle ACTIVITY 0/ 30 main.py Load default template. 1 import the turtle and random modules 2 import turtle 3 import random 6 the commented out random. seed function below initializes the randon seed. 7 behave differently each time the program is run, leave it commented out. If you want 8 your progras to draw the same squares each time, uncomment the random. seed function To make your program 10 a random.seed("Randy the Turtlel") 11 12 next set up the turtle shape and green color 13 turtle.shape("turtle') 14 turtle.color('green') 15 16 now find a random distance, and have the turtle move that distance and turn and move until he draws a square. 17 **insert your code to draw a randomly sizeed square herel 18 19 20 At this point in vour proeram.if all went well. the tuctle has drawna sauare. The following code main.py Load default template 12 next set up the turtle shape and green color 13 turtle.shape("turtle") 14 turtle.color('green") 15 16 now find a randon distance, and have the turtle ove that distance and turn and sove until he draws a square. 17 18 insert your code to draw a randomly sizeed square herel 19 20 At this point in your progran, if al1 went well, the turtle has drana square. The following code 21 picks up the pen, moves the turtle a randon distance aay, and turns the turtle a randon angle, 22 then puts the pen down again to draw. Don't change this part of the code. 23 turtle.penup() 24 turtle.forward(random.randint (10,150)) 25 turtle.right (random.randint(-5,110)) 26 turtle.pendown() 27 28 now insert code below to draw another square, just like you did the first one 29 * don't delete this line also don't delete this line 30 turtle.done() 31 turtle.bye() Description You will be making a program to move Randy the Turtle around and draw a square. The interesting thing about Randy is that he likes to make the square a random size. The random library will help us out with that. Then he'll draw another square. Your task is to: Make Randy move forward a random amount of distance, between 10 and 150 units. Make Randy turn to the left 90 degrees, and move the same amount of distance Make Randy turn 90 degrees left again, move again, etc until he draws a square. We will give you code that will have Randy pick his pen up and move away from the first square and be ready to draw a second square. You will then insert the code to make him draw the second square Notice that unless you set the random seed, each time you run your code, Randy makes different sized squares, and the second one is in a different position. Since this lab won't be auto graded, we don't need to worry about repeating the same set of random numbers like we did in the dice program. So it's fine (and more interesting) to just leave the random.seed() function commented out. IMPORTANT! Do NOT name your file "turtle.py". If you do, you will wipe out the Python turtle package and may damage your entire Anaconda install. While normally you want to give your files descriptive names, you definitely want to avoid name clashes with pre-existing Python packages. A good name might be 'draw_squares.py" or something similar, since later you may also be using the turtle package to draw something Note 1: Running this program in zyBooks does not work. You must run it in Spyder to make it function. When you run the program from Spyder, it creates a window that Randy draws in. In order to run the program a second time (so you can see the different sized squares), you need to close that window. Note 2: Even though you must develop and run your program in Spyder, it MUST submitted for grading in zyBooks before the deadline. You will get a score of 0 from zyBooks; do not be alarmed, the TAS will hand grade your submission from zyBooks. However, if you submit multiple times, make sure that your best submission is your LAST submission, so that the TAS will know which one to grade. The objective of this lab is to practice using function calls for a fun result. There are no automated test cases for this lab, your TA will grade it. Feel free to play around with other turtle functions and draw other things. LAB 16.11.1: Lab 5C: Randy the Turtle ACTIVITY 0/ 30 main.py Load default template. 1 import the turtle and random modules 2 import turtle 3 import random 6 the commented out random. seed function below initializes the randon seed. 7 behave differently each time the program is run, leave it commented out. If you want 8 your progras to draw the same squares each time, uncomment the random. seed function To make your program 10 a random.seed("Randy the Turtlel") 11 12 next set up the turtle shape and green color 13 turtle.shape("turtle') 14 turtle.color('green') 15 16 now find a random distance, and have the turtle move that distance and turn and move until he draws a square. 17 **insert your code to draw a randomly sizeed square herel 18 19 20 At this point in vour proeram.if all went well. the tuctle has drawna sauare. The following code main.py Load default template 12 next set up the turtle shape and green color 13 turtle.shape("turtle") 14 turtle.color('green") 15 16 now find a randon distance, and have the turtle ove that distance and turn and sove until he draws a square. 17 18 insert your code to draw a randomly sizeed square herel 19 20 At this point in your progran, if al1 went well, the turtle has drana square. The following code 21 picks up the pen, moves the turtle a randon distance aay, and turns the turtle a randon angle, 22 then puts the pen down again to draw. Don't change this part of the code. 23 turtle.penup() 24 turtle.forward(random.randint (10,150)) 25 turtle.right (random.randint(-5,110)) 26 turtle.pendown() 27 28 now insert code below to draw another square, just like you did the first one 29 * don't delete this line also don't delete this line 30 turtle.done() 31 turtle.bye()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

10. What is meant by a feed rate?

Answered: 1 week ago