本文实例为大家分享了python实现随机漫步的具体代码,供大家参考,具体内容如下
编写randomwalk类
from random import choice
class randomwalk():
def __init__(self,num_points=5000):
self.num_points=num_points
self.x_values=[0]
self.y_values=[0]
def fill_walk(self):
while len(self.x_values)<self.num_points:
x_directi