我们先引入random和turtle
import turtle as t
import random
接着我们写一下相关配置
t.screensize(1000,300)
t.speed(10)
t.color("black","blue")
然后,我们可以写核心代码了
for i in range(10):
x=random.randint(-200,200)
y=random.randint(100,200)
t.penup()
t.goto(x,y)
t.pendown()
t.begin_fill()
t.circle(50)
t.right(90)
t.forward(50)
t.left(90)
t.end_fill()
我们把写的代码拼在一起并点击运行
每次都不一样哦!