Problem Description A two-dimensional random walk simulates the behavior of a particle moving in a grid of points. At each step, the random walker moves north, south, east, or west with an equal probability of 1/4, regardless of previous moves. Using the turtle module write a program that visualizes the steps of a random walker in a 400 x 400 square starting from the origin (i.e., position 0, 0). Use a step of size, n = 20 (i.e. 10 successive steps in one direction from the origin will get to a boundary). Your program shall define the following functions: • draw_bounds (size, center=(0,0)): This function shall draw a square with the given dimension (i.e. size parameter) around a given starting point (i.e. center parameter). NOTE: The turtle must return to the starting point/center position and its initial orientation after drawing the square • step(step_size=20): This function shall implement a single step in the random walk. The turtle moves by the given step_size in a randomly chosen direction i.e. North, South, East or West • walk (limits=(-200, 200)): This function shall iteratively invoke the previously defined step function to implement the random walk until the turtle reaches a boundary (i.e. defined by the given limits). Additionally, this function must return the number of steps taken. Apply the defined functions in your program to implement 1 trial of the random walk. Display the number of steps taken on the screen once the walk is complete.
Problem Description A two-dimensional random walk simulates the behavior of a particle moving in a grid of points. At each step, the random walker moves north, south, east, or west with an equal probability of 1/4, regardless of previous moves. Using the turtle module write a program that visualizes the steps of a random walker in a 400 x 400 square starting from the origin (i.e., position 0, 0). Use a step of size, n = 20 (i.e. 10 successive steps in one direction from the origin will get to a boundary). Your program shall define the following functions: • draw_bounds (size, center=(0,0)): This function shall draw a square with the given dimension (i.e. size parameter) around a given starting point (i.e. center parameter). NOTE: The turtle must return to the starting point/center position and its initial orientation after drawing the square • step(step_size=20): This function shall implement a single step in the random walk. The turtle moves by the given step_size in a randomly chosen direction i.e. North, South, East or West • walk (limits=(-200, 200)): This function shall iteratively invoke the previously defined step function to implement the random walk until the turtle reaches a boundary (i.e. defined by the given limits). Additionally, this function must return the number of steps taken. Apply the defined functions in your program to implement 1 trial of the random walk. Display the number of steps taken on the screen once the walk is complete.
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
Related questions
Concept explainers
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Question
please write in python languag and by end include the output to make sure it works.
thanks
Template:
# imports
def draw_bounds(size, center=(0, 0)):
"""This function shall draw a square with the given dimension (i.e. size parameter)
around a given starting point (i.e. center parameter).
NOTE: The turtle must return to the starting point/center position
and its initial orientation after drawing the square"""
def step(step_size=20):
"""This function shall implement a single step in the random walk.
The turtle moves by the given step_size in a randomly chosen
direction i.e. North, South, East or West"""
def walk(limits=(-200, 200)):
"""This function shall iteratively invoke the step function to implement
the random walk until the turtle reaches a boundary (i.e. defined by the given limits).
Additionally, this function must return the number of steps taken."""
if __name__ == '__main__':
...

Transcribed Image Text:2-D Random Walk
Steps taken= 142,
T
0
X

Transcribed Image Text:Problem Description
A two-dimensional random walk simulates the behavior of a particle moving in a grid of points.
At each step, the random walker moves north, south, east, or west with an equal probability of
1/4, regardless of previous moves.
Using the turtle module write a program that visualizes the steps of a random walker in a
400 x 400 square starting from the origin (i.e., position 0, 0). Use a step of size, n = 20 (i.e. 10
successive steps in one direction from the origin will get to a boundary).
Your program shall define the following functions:
•
draw_bounds (size, center= (0,0)): This function shall draw a square with the
given dimension (i.e. size parameter) around a given starting point (i.e. center
parameter). NOTE: The turtle must return to the starting point/center position and its
initial orientation after drawing the square
step(step_size=20): This function shall implement a single step in the random walk.
The turtle moves by the given step_size in a randomly chosen direction i.e. North,
South, East or West
• walk (limits=(-200, 200)): This function shall iteratively invoke the previously
defined step function to implement the random walk until the turtle reaches a boundary
(i.e. defined by the given limits). Additionally, this function must return the number of
steps taken.
Apply the defined functions in your program to implement 1 trial of the random walk. Display
the number of steps taken on the screen once the walk is complete.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education