猫史档案馆


【Python作品分享】圣诞树【作品秀】

用户:quuuquuu查看:0 回复:0 评论:0 创建时间:2020-10-11T16:26:42


【作品展示】

center_image

 

【作品介绍】

圣诞树

 

【作品源代码】

import turtle

screen = turtle.Screen()
screen.setup(375, 700)

circle = turtle.Turtle()
circle.shape('circle')
circle.color('red')
circle.speed('fastest')
circle.up()

喵 = turtle.Turtle()
喵.shape('喵')
喵.color('green')
喵.speed('fastest')
喵.up()

circle.goto(0, 280)
circle.stamp()

k = 0
for i in range(1, 13):
    y = 30*i
    for j in range(i-k):
        x = 30*j
        喵.goto(x, -y+280)
        喵.stamp()
        喵.goto(-x, -y+280)
        喵.stamp()

    if i % 4 == 0:
        x = 30*(j+1)
        circle.color('red')
        circle.goto(-x, -y+280)
        circle.stamp()
        circle.goto(x, -y+280)
        circle.stamp()
        k += 3

    if i % 4 == 3:
        x = 30*(j+1)
        circle.color('yellow')
        circle.goto(-x, -y+280)
        circle.stamp()
        circle.goto(x, -y+280)
        circle.stamp()

喵.color('brown')
for i in range(13, 17):
    y = 30*i
    for j in range(2):
        x = 30*j
        喵.goto(x, -y+280)
        喵.stamp()
        喵.goto(-x, -y+280)
        喵.stamp()

text = turtle.Turtle()
text.hideturtle()
text.penup()
text.goto(-120, 270)
text.color('red')
text.write('圣诞快乐', font=('SimHei', 18, 'bold'))
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页