import numpy as np
import random
import matplotlib.pyplot as plt
position = 0
walk = [position]
steps = 1000
for i in range(steps):
step = 1 if random.randint(0,1) else -1
position += step
walk.append(position)
plt.plot(walk[:100])
#random.randint(参数1,参数2)
#参数1、参数2必须是整数
#函数返回参数1和参数2之间的任意整数
```python
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210421172019202.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2NoYW9xaWNoYW9sdW9l,size_16,color_FFFFFF,t_70)
05-27
2152
09-20