猫史档案馆


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

用户:豪爽的萌萌熊fZ7B豪爽的萌萌熊fZ7B查看:0 回复:1 评论:0 创建时间:2021-05-05T20:53:02


【作品展示】

center_image

 

【作品介绍】

每一张星空图都是独一无二的,让我们一起在星海中畅游吧!

 

【作品源代码】

import turtle
import random

__Pen = turtle.Pen()


def 画小星星():

    __Pen.penup()
    __Pen.pencolor("#ffff99")
    __Pen.goto(random.randint((-280), 280), random.randint((-280), 280))
    __Pen.pendown()
    __Pen.dot(random.randint(2, 3))

def 画大星星():

    __Pen.penup()
    x, y, a = random.randint((-280), 280), random.randint((-280), 280), random.randint(3, 10)
    __Pen.pencolor("#ffffff")
    __Pen.fillcolor("#ffffcc")
    __Pen.pensize(2)
    __Pen.goto((x - a), y)
    __Pen.begin_fill()
    __Pen.pendown()
    __Pen.circle(a, 90)
    __Pen.penup()
    __Pen.goto(x, (y - a))
    __Pen.pendown()
    __Pen.circle(a, 90)
    __Pen.penup()
    __Pen.goto((x + a), y)
    __Pen.pendown()
    __Pen.circle(a, 90)
    __Pen.penup()
    __Pen.goto(x, (y + a))
    __Pen.pendown()
    __Pen.circle(a, 90)
    __Pen.end_fill()

#开始进入Python的世界
turtle.bgcolor("#000066")
for __count in range(random.randint(15, 30)):
    画小星星()
for __count in range(random.randint(1, 7)):
    画大星星()
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
Holmes_AxHolmes_Ax

夜   空   上   的   北   斗   七   星(

点赞0


评论