1062195630 发表于 2021-6-27 20:35:56

python随机漫步

import matplotlib.pyplot as plt
import random
position=0
walk=
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])


为啥出不来图呢

Twilight6 发表于 2021-6-27 20:47:33



最后一行加上代码即可:plt.show()

页: [1]
查看完整版本: python随机漫步