QuestionQuestion

Part 1 is Write a script wander.py that creates a turtle that walks around randomly, and then finds serenity. When the script is run:
1. A new screen should be created (using scrn = turtle.Screen()), and a new turtle as well.
2. Immediately set the turtle’s speed to 0 (fastest), using
<your turtle name>.speed(0) (replacing<your turtle name>withthenameofyourturtle)
This represents the young turtle’s busy pace and the unrest in its soul.
3. Repeat the following 250 times:
1. Take 15 steps forward
2. Turn in a random direction
(This part is very similar to the wandering script we wrote in class for Lecture 16)
This represents the turtle’s meandering journey of self-discovery.
4. After this, your screen should look like a random tangled mess.
5. Have your turtle draw a tight box around the entire region that the turtle wandered.
This box should encompass the entire “tangled mess”, and describes the turtle’s introspection of how far it has come.
This box should be tight: it should be as small as possible to cover the tangled mess. See the examples for a visual explanation.
6. Move the turtle to the very center of this box, and stamp its image (using <your turtle name>.stamp()), to signify that it has found finally found its inner peace.
7. Be sure to end the script with scrn.exitonclick().
This represents the turtle’s realization that nothing in this world is permanent.

Part 2 is-
Write a module grid.py with a single function def drawgrid(turt, size, width, height):
That takes a turtle, a float for a square size, a width int, and a height int, and draws a grid of squares (with side length size) that is width squares wide and height squares tall.
You can test it out like this, on the REPL:
That should draw a 5 × 6 grid, where each square is 50 × 50 steps.

IMPORTANT: This module should not directly create a screen or a turtle!! It should only contain exactly one function (drawgrid()), nothing more and nothing less. The module should not create a screen or a turtle, but rather, drawgrid() should use the turtle that is given to it as an argument.
When you test drawgrid, you should be creating a screen and turtle and giving that turtle to grid.drawgrid(), as shown in the example above. But drawgrid() or grid.py themselves should not create any screens or any turtles.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

scrn = turtle.Screen()
t = turtle.Turtle()

t.speed(0)

# Variables to keep track of rectangular bounds
minX = 0
minY = 0
maxX = 0
maxY = 0

# Wander randomly 250 times
for i in range(250):
    t.forward(15)
    angle = random.randint(1,359)
    t.left(angle)
    x, y = t.pos()
    if x < minX:
       minX = x
    if x > maxX...

By purchasing this solution you'll be able to access the following files:
Solution.PNG, Solution1.PNG, Solution.py and Solution1.py.

$35.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats