decide which direction to go and how far to go in that direction x_direction choice([ - ]x_distance choice([ ]x_step x_direction x_distance y_direction choice([ - ]y_distance choice([ ]y_step y_direction y_distance reject moves that go nowhere if x_step = and y_step = continue calculate the next and values next_x self x_values[- x_step next_y self y_values[- y_step self x_values append(next_xself y_values append(next_yat we set up loop that runs until the walk is filled with the correct number of points the main part of this method tells python how to simulate four random decisionswill the walk go right or lefthow far will it go in that directionwill it go up or downhow far will it go in that directionwe use choice([ - ]to choose value for x_directionwhich returns either for right movement or - for left nextchoice([ ]tells python how far to move in that direction (x_distanceby randomly selecting an integer between and (the inclusion of allows us to take steps along the -axis as well as steps that have movement along both axes at and we determine the length of each step in the and directions by multiplying the direction of movement by the distance chosen positive result for x_step moves us righta negative result moves us leftand moves us vertically positive result for y_step means move upnegative means move downand means move horizontally if the value of both x_step and y_step are the walk stopsbut we continue the loop to prevent this to get the next -value for our walkwe add the value in x_step to the last value stored in x_values and do the same for the -values once we have these valueswe append them to x_values and y_values plotting the random walk here' the code to plot all the points in the walkrw_visual py import matplotlib pyplot as plt from random_walk import randomwalk make random walkand plot the points rw randomwalk(rw fill_walk(generating data