from random import random STEPS = 60 * 30 # one step each second for thirty minutes WALKS = 365 # one for each day of the year # define starting values sum_x = 0 sum_y = 0 # run the experiment for num_exp in range(WALKS): # define starting location x = 0 y = 0 # take a walk for i in range(STEPS): if random() < 0.5: change = 1 else: change = -1 if random() < 0.5: x += change else: y += change sum_x += x sum_y += y # print final location print(sum_x / WALKS, sum_y / WALKS)