猫史档案馆


【Python作品分享】遵义Python编程综合测评【作业帖】

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


【作品展示】

center_image

 

【作品介绍】

知识点: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


回复

上一页1 页 / 共 1下一页
老盛本人老盛本人

你可以用speed指令来调节速度,不然感觉有点慢,加油emotion_编程猫_加油

点赞0


评论


王W羽王W羽

???

turtle.done()

好像是

t.done()

点赞0


评论