用户:
Jim_shooter查看:0 回复:0 评论:0 创建时间:2021-05-23T08:20:34
【作品展示】

【作品介绍】
给航天员的一张明信片你可以给航天员一个火箭
也可以写下想跟航天员说的话
还可以送上一张太阳系的图片(效果图)
其他的效果自行实验啦~
【作品源代码】
import turtle as t
import time
import math
import random
def send(answer):
if answer == 1:
rocket()
elif answer == 2:
say()
elif answer == 3:
solar_system()
def solar_system():
t.setup(1000, 1000)
t.bgcolor("black")
t.speed(20)
# 太阳
t.color("red", "red")
t.penup()
t.goto(0, -60)
t.pendown()
t.begin_fill()
t.circle(100)
t.end_fill()
t.penup()
t.goto(0, 0)
t.pencolor("blue")
t.pendown()
t.write("太阳", align='center', font=('fangzheng', 50))
# 水星
t.penup()
t.pencolor("white")
t.goto(0, -90)
t.pendown()
t.circle(130)
t.color("goldenrod", "goldenrod")
t.penup()
t.goto(-100, -43)
t.pendown()
t.begin_fill()
t.circle(3)
t.end_fill()
t.pencolor("red")
t.penup()
t.goto(-130, -47)
t.pendown()
t.write("水星→", align='center', font=('fangzheng', 10))
# 金星
t.penup()
t.pencolor("white")
t.goto(0, -130)
t.pendown()
t.circle(170)
t.color("gold", "gold")
t.penup()
t.goto(100, -100)
t.pendown()
t.begin_fill()
t.circle(6)
t.end_fill()
t.pencolor("red")
t.penup()
t.goto(100, -120)
t.pendown()
t.write("金星↑", align='center', font=('fangzheng', 10))
# 地球
t.penup()
t.pencolor("white")
t.goto(0, -160)
t.pendown()
t.circle(200)
t.color("royalblue", "royalblue")
t.penup()
t.goto(-180, -60)
t.pendown()
t.begin_fill()
t.circle(7)
t.end_fill()
t.pencolor("red")
t.penup()
t.goto(-210, -60)
t.pendown()
t.write("地球→", align='center', font=('fangzheng', 10))
# 火星
t.penup()
t.pencolor("white")
t.goto(0, -210)
t.pendown()
t.circle(250)
t.color("darkred", "darkred")
t.penup()
t.goto(230, -60)
t.pendown()
t.begin_fill()
t.circle(4)
t.end_fill()
t.pencolor("blue")
t.penup()
t.goto(230, -80)
t.pendown()
t.write("火星↑", align='center', font=('fangzheng', 10))
# 木星
t.penup()
t.pencolor("white")
t.goto(0, -260)
t.pendown()
t.circle(300)
t.color("lightyellow", "lightyellow")
t.penup()
t.goto(0, -295)
t.pendown()
t.begin_fill()
t.circle(30)
t.end_fill()
t.pencolor("blue")
t.penup()
t.goto(0, -275)
t.pendown()
t.write("木星", align='center', font=('fangzheng', 15))
# 土星
t.penup()
t.pencolor("white")
t.goto(0, -310)
t.pendown()
t.circle(350)
t.color("coral", "coral")
t.penup()
t.goto(-200, -275)
t.pendown()
t.begin_fill()
t.circle(25)
t.end_fill()
t.pencolor("blue")
t.penup()
t.goto(-200, -265)
t.pendown()
t.write("土星", align='center', font=('fangzheng', 15))
# 天王星
t.penup()
t.pencolor("white")
t.goto(0, -350)
t.pendown()
t.circle(400)
t.color("skyblue", "skyblue")
t.penup()
t.goto(200, -310)
t.pendown()
t.begin_fill()
t.circle(15)
t.end_fill()
t.pencolor("red")
t.penup()
t.goto(160, -300)
t.pendown()
t.write("天王星→", align='center', font=('fangzheng', 10))
# 海王星
t.penup()
t.pencolor("white")
t.goto(0, -380)
t.pendown()
t.circle(430)
t.color("mediumblue", "mediumblue")
t.penup()
t.goto(-200, -340)
t.pendown()
t.begin_fill()
t.circle(13)
t.end_fill()
t.pencolor("red")
t.penup()
t.goto(-240, -340)
t.pendown()
t.write("海王星→", align='center', font=('fangzheng', 10))
t.hideturtle()
print("这就是太阳系啦,宇航员收到会赞叹你的画技的!邮递员,走喽!")
t.done()
def say():
print("好的!请问你要对宇航员说什么话?这里有些智能选项,或者你可以自定义回答!")
print("1.宇航员们,你们的一小步,将是人类的一大步,走好这一步,以后步步不愁,加油!\n2.宇航员们,你们肩负着的,是背后十四亿中国人民的航天梦!帮助他们实现吧,在这喵之际!\n3.宇航员们,你们可曾想过,有多少人想要实现他的航天梦,机会却给了你们。你们更应好好珍惜,不辱使命,给祖国添光彩!\n4.自定义回答")
say_answer = int(input("请选择(纯数字):"))
if say_answer == 1:
print("好的,请确认你要对宇航员说的话:宇航员们,你们的一小步,将是人类的一大步,走好这一步,以后步步不愁,加油!")
a = int(input("请选择\n1.确认\n2.取消(纯数字):"))
if a == 1:
print("好的,你对宇航员说的话已经写进了明信片,邮递员会竭尽全力运送的!")
else:
say()
elif say_answer == 2:
print("好的,请确认你要对宇航员说的话:宇航员们,你们的一小步,将是人类的一大步,走好这一步,以后步步不愁,加油!")
b = int(input("请选择\n1.确认\n2.取消(纯数字):"))
if b ==1:
print("好的,你对宇航员说的话已经写进了明信片,邮递员会竭尽全力运送的!")
else:
say()
elif say_answer == 3:
print("好的,请确认你要对宇航员说的话:宇航员们,你们可曾想过,有多少人想要实现他的航天梦,机会却给了你们。你们更应好好珍惜,不辱使命,给祖国添光彩!")
c = int(input("请选择\n1.确认\n2.取消(纯数字):"))
if c == 1:
print("好的,你对宇航员说的话已经写进了明信片,邮递员会竭尽全力运送的!")
else:
say()
elif say_answer == 4:
d = input("OK,请写下你要说的话:")
print("好的,请确认你要对宇航员说的话:{}".format(d))
e = int(input("请选择\n1.确认\n2.取消(纯数字):"))
if e == 1:
print("好的,你对宇航员说的话已经写进了明信片,邮递员会竭尽全力运送的!")
else:
say()
def rocket():
t.bgcolor('black')
t.speed(0)
# 星星
t.fillcolor('gold')
t.color('gold')
star_x, star_y = 0, 0
for i in range(50):
t.penup()
t.goto(random.randint((-300), 300), random.randint((-300), 300))
t.setheading(random.randint(0, 180))
t.pendown()
t.begin_fill()
for i in range(5):
t.forward(10)
t.left(72)
t.forward(10)
t.right(144)
t.end_fill()
# 火箭顶端
t.setheading(0)
t.fillcolor('yellow')
t.color('yellow')
t.penup()
t.goto(0, 300)
t.pendown()
t.begin_fill()
t.right(60)
t.forward(80)
for i in range(2):
t.right(120)
t.forward(80)
t.end_fill()
# 火箭第二层(载人+窗户)
t.setheading(0)
t.fillcolor('dodger blue')
t.color('dodger blue')
t.penup()
t.goto((-25), 230)
t.pendown()
t.begin_fill()
for i in range(2):
t.forward(50)
t.right(90)
t.forward(130)
t.right(90)
t.end_fill()
t.pencolor('white')
t.penup()
t.goto(0, (230 - 65))
t.pensize(3)
t.pendown()
t.circle(10)
# 火箭第三层(主推进器)
t.setheading(0)
t.pensize(1)
t.fillcolor('blue')
t.color('blue')
t.penup()
t.goto((-40), 100)
t.pendown()
t.begin_fill()
t.forward(80)
t.right(90)
t.forward(200)
t.right(90)
t.forward(80)
t.right(90)
t.forward(200)
t.right(90)
t.end_fill()
# 副推进器
t.setheading(0)
t.fillcolor('sky blue')
t.color('sky blue')
p = 1
for i in range(2):
t.penup()
if (p == 1):
t.goto((-100), 10)
p += 1
else:
t.goto(40, 10)
t.pendown()
t.begin_fill()
for i in range(2):
t.forward(60)
t.right(90)
t.forward(110)
t.right(90)
t.end_fill()
# 火焰
t.setheading(0)
t.fillcolor('orange')
t.color('orange')
x, y = 0, 0
w = 1
for i in range(3):
t.setheading(0)
t.penup()
if (w == 1 or w == 3):
if (w == 1):
x, y = (-100), (-105)
w += 1
if (w == 3):
x, y = 40, (-105)
t.goto(x, y)
t.pendown()
t.begin_fill()
t.forward(60)
t.right(100)
for i in range(2):
t.forward(150)
t.right(158)
t.end_fill()
else:
x, y = (-42), (-105)
w += 1
t.goto(x, y)
t.pendown()
t.begin_fill()
t.forward(80)
t.right(100)
for i in range(2):
t.forward(200)
t.right(158)
t.end_fill()
# 写字
t.penup()
t.goto((-20), 70)
t.pendown()
t.write("中", align='center', font=('fangzheng', 20))
t.penup()
t.goto((-20), 45)
t.pendown()
t.write("国", align='center', font=('fangzheng', 20))
t.penup()
t.goto((-20), 20)
t.pendown()
t.write("载", align='center', font=('fangzheng', 20))
t.penup()
t.goto((-20), (-5))
t.pendown()
t.write("人", align='center', font=('fangzheng', 20))
t.penup()
t.goto((-20), (-30))
t.pendown()
t.write("航", align='center', font=('fangzheng', 20))
t.penup()
t.goto((-20), (-55))
t.pendown()
t.write("天", align='center', font=('fangzheng', 20))
t.hideturtle()
print("这就是你要寄给宇航员的火箭,邮递员,走喽!")
time.sleep(5)
print('欢迎来到邮局!你想要寄给宇航员里面有什么内容的明信片?\n1.火箭\n2.想对宇航员说的话\n3.太阳系的图片')
answer = int(input("请选择(纯数字):"))
send(answer)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn