please fix this code the turtle suppose to start from center but my code start from side which is wrong please fix it. please do it in python language and my code is also in python. please include the out put of the snip it.   thanks   code:   import turtle import random   def draw_bounds(size, center=(0,0)):     turtle.penup()     turtle.goto(center)     turtle.setheading(0)     turtle.pendown()     turtle.forward(size/2)     turtle.left(90)     turtle.forward(size/2)     turtle.left(90)     turtle.forward(size)     turtle.left(90)     turtle.forward(size)     turtle.left(90)     turtle.forward(size)     turtle.left(90)     turtle.forward(size/2)     turtle.left(90)     turtle.forward(size/2)     turtle.penup()     turtle.goto(center)     turtle.pendown()   def step(step_size=20):     directions = ['north', 'south', 'east', 'west']     direction = random.choice(directions)     if direction == 'north':         turtle.setheading(90)         turtle.forward(step_size)     elif direction == 'south':         turtle.setheading(270)         turtle.forward(step_size)     elif direction == 'east':         turtle.setheading(0)         turtle.forward(step_size)     elif direction == 'west':         turtle.setheading(180)         turtle.forward(step_size)   def walk(limits =(-200, 200)):     steps = 0     while True:         x, y = turtle.position()         if abs(x) >= limits[1] or abs(y) >= limits[1]:             break         step()         steps += 1     return steps   turtle.speed('fastest') turtle.hideturtle() draw_bounds(400) turtle.showturtle() steps = walk((0, 200)) turtle.write("Number of Steps: {}".format(steps), font=("Arial", 14, "bold"), align="center") turtle.done()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

please fix this code the turtle suppose to start from center but my code start from side which is wrong please fix it.

please do it in python language and my code is also in python. please include the out put of the snip it.

 

thanks

 

code:

 

import turtle
import random

 

def draw_bounds(size, center=(0,0)):
    turtle.penup()
    turtle.goto(center)
    turtle.setheading(0)
    turtle.pendown()
    turtle.forward(size/2)
    turtle.left(90)
    turtle.forward(size/2)
    turtle.left(90)
    turtle.forward(size)
    turtle.left(90)
    turtle.forward(size)
    turtle.left(90)
    turtle.forward(size)
    turtle.left(90)
    turtle.forward(size/2)
    turtle.left(90)
    turtle.forward(size/2)
    turtle.penup()
    turtle.goto(center)
    turtle.pendown()

 

def step(step_size=20):
    directions = ['north', 'south', 'east', 'west']
    direction = random.choice(directions)
    if direction == 'north':
        turtle.setheading(90)
        turtle.forward(step_size)
    elif direction == 'south':
        turtle.setheading(270)
        turtle.forward(step_size)
    elif direction == 'east':
        turtle.setheading(0)
        turtle.forward(step_size)
    elif direction == 'west':
        turtle.setheading(180)
        turtle.forward(step_size)

 

def walk(limits =(-200, 200)):
    steps = 0
    while True:
        x, y = turtle.position()
        if abs(x) >= limits[1] or abs(y) >= limits[1]:
            break
        step()
        steps += 1
    return steps

 

turtle.speed('fastest')
turtle.hideturtle()
draw_bounds(400)
turtle.showturtle()
steps = walk((0, 200))
turtle.write("Number of Steps: {}".format(steps), font=("Arial", 14, "bold"), align="center")
turtle.done()
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education