用户:
调皮的超能鸭2NEq查看:1 回复:2 评论:1 创建时间:2020-06-07T10:57:45
【作品展示】

【作品介绍】
知识点:for循环,while循环,函数的综合使用。
【作品源代码】
import turtle
import random
t = turtle.Pen()
turtle.bgcolor("pink")
t.pensize(5)
colors = ["red", "black", "white", "orange"]
def my_square(y, z):
t.penup()
t.goto(y, z)
t.pendown()
t.pencolor(colors[random.randint(0, 3)])
for i in range(6):
for j in range(4):
t.fd(50)
t.left(90)
t.left(360/6)
n = int(input("请输入你要绘制多少个图形:"))
m = 0
while(m < n):
x = random.randint(-500, 500)
y = random.randint(-300, 300)
my_square(x, y)
m = m+1
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn