猫史档案馆


【Python作品分享】【36强进10】定制给杨利伟叔叔的明信片【作品秀】

用户:含蓄的暴风雀7mia含蓄的暴风雀7mia查看:0 回复:0 评论:0 创建时间:2021-05-22T17:35:19


【作品展示】

center_image

 

【作品介绍】

这是给航天人杨利伟叔叔的明信片。

用法:可以任意输入自己想对他说的话,

然后记得写上自己的名字哦。

这样杨利伟叔叔就能收到你送的明信片了。

 

【作品源代码】

import turtle
import random
mypen = turtle.Pen()
myscreen = turtle.Screen()
mypen.speed(0)
myscreen.bgcolor("black")


def work_into(x, y):
    mypen.penup()
    mypen.goto(x, y)
    mypen.pendown()


mypen.pencolor("orange")


def heng_while_1(v):
    mypen.forward(v)
    mypen.left(2)
    mypen.backward(v)


def heng_while(v):
    mypen.forward(v)
    mypen.left(1)
    mypen.backward(v)


work_into(300, 300)
mypen.dot(60)
work_into(250, 300)
for i in range(1, 180+1):
    heng_while_1(50)

mypen.pencolor("skyblue")
work_into(-100, -100)
mypen.dot(40)
work_into(-130, -100)


def heng_fo(clour, v):
    mypen.pencolor(clour)
    mypen.pensize(3)
    heng_while(v)


heng_fo("lightblue", 60)
mypen.pencolor("yellow")
work_into(150, -200)
mypen.dot(30)
work_into(120, -200)
heng_fo("yellow2", 60)

f_clours = ["yellow", "red", "blue", "green", "white", "purple"]
for i in range(50):
    e = random.randint(5, 20)
    x = random.randint(-400, 400)
    y = random.randint(-400, 400)
    s_clour = random.choice(f_clours)
    work_into(x, y)
    mypen.pencolor(s_clour)
    mypen.dot(e)
mypen.pencolor("red")
work_into(-200, 50)
mypen.begin_fill()
mypen.fillcolor("red")
mypen.left(88)
mypen.forward(100)
mypen.right(45)
mypen.forward(10)
mypen.right(90)
mypen.forward(10)
mypen.right(45)
mypen.forward(100)
mypen.right(90)
mypen.forward(10)
mypen.end_fill()
mypen.backward(5)
mypen.right(90)
mypen.forward(80)
mypen.pencolor("grey2")
mypen.dot(10)
mypen.pencolor("blue")
mypen.dot(6)
work_into(-200, 50)
mypen.left(90)
mypen.begin_fill()
mypen.pencolor("red")
mypen.fillcolor("red")
mypen.forward(10)
mypen.right(135)
mypen.forward(25)
mypen.right(90)
mypen.forward(25)
mypen.right(135)
mypen.forward(30)
mypen.end_fill()
mypen.backward(15)
mypen.left(90)
mypen.pencolor("gold")
mypen.pensize(7)
mypen.forward(20)
mypen.right(90)
work_into(-400, 200)
mypen.pencolor("red")
mypen.write("To 杨利伟叔叔", font=("文泉驿正黑", 30))
work_into(-200, -100)
mypen.pencolor("skyblue")
mypen.dot(100)
c_clours = ["blue", "green"]

for i in range(15):
    a = random.randint(5, 15)
    x = random.randint(-235, -170)
    y = random.randint(-133, -60)
    s_clour = random.choice(c_clours)
    work_into(x, y)
    mypen.pencolor(s_clour)
    mypen.dot(a)
mypen.pensize(7)
for i in range(5):
    a = random.randint(5, 15)
    x = random.randint(-230, -175)
    y = random.randint(-130, -65)
    s_clour = random.choice(c_clours)
    work_into(x, y)
    mypen.pencolor(s_clour)
    mypen.forward(a)
work_into(-400, 150)
mypen.pencolor("grey")
mypen.write("喵个踏上太空的航天员!", font=("文泉驿正黑", 30))
work_into(-400, 100)
mypen.write("他是我们的骄傲,也是祖国的骄傲。", font=("文泉驿正黑", 30))
work_into(-400, 50)
mypen.write("没有他勇敢的踏出第一步,就起不了好榜样!", font=("文泉驿正黑", 30))
work_into(-400, 0)
mypen.write("他造福人类,带领大家去探索科学这座宏大的桥!", font=("文泉驿正黑", 30))

mypen.pencolor("silver")
work_into(350, -200)
mypen.begin_fill()
mypen.fillcolor("silver")
mypen.forward(100)
mypen.right(45)
mypen.forward(10)
mypen.right(90)
mypen.forward(10)
mypen.right(45)
mypen.forward(100)
mypen.right(90)
mypen.forward(10)
mypen.end_fill()
mypen.backward(5)
mypen.right(90)
mypen.forward(80)
mypen.pencolor("grey2")
mypen.dot(10)
mypen.pencolor("blue")
mypen.dot(6)
work_into(350, -200)
mypen.left(90)
mypen.begin_fill()
mypen.pencolor("silver")
mypen.fillcolor("silver")
mypen.forward(10)
mypen.right(135)
mypen.forward(25)
mypen.right(90)
mypen.forward(25)
mypen.right(135)
mypen.forward(30)
mypen.end_fill()
mypen.backward(15)
mypen.left(90)
mypen.pencolor("gold")
mypen.pensize(7)
mypen.forward(20)


def star(size, color):
    mypen.pencolor(color)
    mypen.begin_fill()
    mypen.fillcolor(color)
    for i in range(5):
        mypen.forward(size)
        mypen.left(72)
        mypen.forward(size)
        mypen.right(144)
    mypen.end_fill()


work_into(310, -186)
mypen.left(90)
mypen.pencolor("white")
mypen.forward(50)
mypen.right(90)
mypen.pencolor("red")
mypen.begin_fill()
mypen.fillcolor("red")

mypen.forward(30)
mypen.right(90)
mypen.forward(20)
mypen.right(90)
mypen.forward(30)
mypen.right(90)
mypen.forward(20)
mypen.right(90)

mypen.pencolor()


mypen.end_fill()

work_into(315,-145)
star(3,"gold")
work_into(-400, -300)
wte = input("说一句话送给杨利伟吧:")
mypen.write("寄语:", font=("文泉驿正黑", 30))
work_into(-300, -300)
mypen.write(wte, font=("文泉驿正黑", 30))
work_into(200, -380)
name = input("留下姓名吧:")
mypen.write("from:", font=("文泉驿正黑", 30))
work_into(300, -380)
mypen.write(name, font=("文泉驿正黑", 30))
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页