猫史档案馆


【Python作品分享】【去太空,去编程】星星【作品秀】

用户:自律的大泡泡自律的大泡泡查看:0 回复:0 评论:0 创建时间:2021-05-05T17:27:27


【作品展示】

center_image

 

【作品介绍】

漫天的星星在太空中

 

【作品源代码】

import turtle
import random
import turtle as t
import random  # 导入随机数
from random import randint


# 设置绘画速度
t.speed(0)




turtle.bgcolor('black')
# 设置绘画速度
t.speed(0)
# 设置画笔颜色
t.pencolor('yellow')
t.fillcolor('yellow')
t.penup()
for i in range(40):
    t.begin_fill()
    # 随机x坐标
    x = random.randint(-300, 300)
    # 随机y坐标
    y = random.randint(-250, 250)
    # 把画笔移动到(x,y)
    t.goto(x, y)
    # 落笔
    t.pendown()
    for i in range(5):
        t.forward(30)
        t.right(144)
    # 抬笔
    t.penup()
    t.end_fill()
# 阻止自动关闭窗口
t.hideturtle()
t.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页