Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview The turtle package in Python is used to make simple graphics programs. It is based around the idea of a turtle holding a pen

image text in transcribed
image text in transcribed
image text in transcribed
Overview The turtle package in Python is used to make simple graphics programs. It is based around the idea of a turtle holding a pen that you can program to move around the screen. As the turtle moves around the screen, it draws a line behind it. The two functions we will be using in this lab are: turtle. forward(distance) this function takes in one argument which represents how far the turtle should walk forward. turtle.left(degrees): this function takes in one argument which represents how much the turtle should turn to the left. 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. IMPORTANTI DO NOT name your file 'turtlepyIf 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 O from zyBooks, do not be alarmed, the TAs will hand grade your submission from 2yBooks. However, if you submit multiple times, make sure that your best submission is your LAST submission, so that the As will know which one to grade. Once again, the TAs will grade the LAST submission you had submitted to zyBooks before the deadline. Objective 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. ACTIVITY 16.11.1:Lab 5C: Randy the Turtle 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 random seed. To make your program 7. behave differently each time the program is run, leave it commented out. If you want 8. your program to draw the same squares each time, uncomment the random seed function 10 # random seed("Randy the Turtle!") 12 # next set up the turtle shape and green color, 13 turtle.shope('turtle") 14 turtle.color('green') 16. now find a randon distance, and have the turtle nove that distance and turn and move unt 18 insert your code to draw a randomly sizeed square here! Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box Enter program input (optional) if your code requires input values, provide them here 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. ACTIVITY 16.11.1: Lab 5C: Randy the Turtle 0/30 main.py Load default template... 14 turtle.color('green') 19 16 now find a random distance, and have the turtle move that distance and turn and move until he drons a square. 18 'insert your code to draw a randomly sizeed square here!" 20. At this point in your program, if all went well, the turtle has drawn a square. The following code 21 # picks up the pen, moves the turtle a random distance away, and turns the turtle a random angle, 22 then puts the pen down again to draw. Don't change this part of the code. 23 turtle.penup 24 turtle forward randomrandint(10, 150)) 25 turtle.right (randon.randint(-5, 110)) 26 turtle.pendown() 28 now insert code below to draw another square, Just like you did the first one 29 30 turtle.done 31 turtle.bye don't delete this one also don't delete this line

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Psychologists must practice within the boundaries of competence.

Answered: 1 week ago

Question

Identify three types of physicians and their roles in health care.

Answered: 1 week ago

Question

Compare the types of managed care organizations (MCOs).

Answered: 1 week ago