猫史档案馆


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

用户:马虎的炸弹人nzgo马虎的炸弹人nzgo查看:0 回复:3 评论:0 创建时间:2021-05-05T20:58:03


【作品展示】

center_image

 

【作品介绍】

这个是我的作品的其中一个——简易火箭。我做这个程序是想要让大家了解我,并且学会如何有手就可以画出简易太阳系和简易火箭,希望大家能够喜欢我的作品。

 

【作品源代码】

import time
import turtle


Name = input('你叫什么名字?')
print('你好', Name, '欢迎来到绘画教室。')
time.sleep(1.5)
print('你想干什么?\n1.认识认识我。\n2.学学怎么画简易太阳系。\n3.学学怎么画简易火箭。')
choice1 = input('你决定:')
if (choice1 == '1'):
    t = turtle.Pen()
    t.pensize(10)
    t.speed(5)
    turtle.bgcolor('black')
    t.hideturtle()
    t.pencolor('yellow')
    t.penup()
    t.goto(0, 100)
    t.pendown()
    t.setheading(45)
    t.forward(100)
    t.penup()
    t.goto(0, 120)
    t.pendown()
    t.forward(100)
    t.penup()
    t.goto(50, 150)
    t.setheading((-90))
    t.pendown()
    t.forward(100)
    t.penup()
    t.goto(75, 150)
    t.setheading(45)
    t.pendown()
    t.forward(75)
    t.setheading((-45))
    t.forward(75)
    t.penup()
    t.goto(90, 140)
    t.setheading(0)
    t.pendown()
    t.forward(80)
    t.penup()
    t.goto(80, 110)
    t.pendown()
    t.forward(100)
    t.penup()
    t.goto(130, 140)
    t.setheading((-90))
    t.pendown()
    t.forward(85)
    t.setheading(135)
    t.forward(30)
    t.penup()
    t.goto(100, 90)
    t.setheading(225)
    t.pendown()
    t.forward(30)
    t.penup()
    t.goto(150, 90)
    t.setheading((-45))
    t.pendown()
    t.forward(30)
    t.pencolor('green')
    t.penup()
    t.goto(220, 190)
    t.setheading(0)
    t.pendown()
    t.forward(100)
    t.setheading(220)
    t.forward(70)
    t.setheading((-90))
    t.forward(90)
    t.setheading(135)
    t.forward(45)
    t.penup()
    t.goto(195, 145)
    t.setheading(0)
    t.pendown()
    t.forward(150)
    t.pencolor('red')
    t.penup()
    t.goto(360, 190)
    t.setheading((-45))
    t.pendown()
    t.forward(50)
    t.penup()
    t.goto(360, 150)
    t.setheading((-45))
    t.pendown()
    t.forward(50)
    t.penup()
    t.goto(360, 60)
    t.setheading(45)
    t.pendown()
    t.forward(55)
    t.penup()
    t.goto(430, 190)
    t.setheading(0)
    t.pendown()
    t.forward(70)
    t.penup()
    t.goto(500, 190)
    t.setheading((-135))
    t.pendown()
    t.forward(60)
    t.setheading((-90))
    t.forward(90)
    t.setheading(135)
    t.forward(30)
    t.speed(0)
    t.penup()
    t.setheading((-45))
    t.forward(30)
    t.setheading(90)
    t.forward(60)
    t.setheading(135)
    t.forward(40)
    t.speed(5)
    t.pendown()
    t.setheading((-45))
    t.forward(40)
    t.setheading((-135))
    t.forward(45)
    t.speed(0)
    t.penup()
    t.setheading(45)
    t.forward(90)
    t.speed(5)
    t.setheading((-135))
    t.pendown()
    t.forward(45)
    t.setheading((-45))
    t.forward(45)
    t.penup()
    t.setheading(135)
    t.forward(105)
    t.pendown()
    t.setheading((-90))
    t.forward(110)
    t.setheading(0)
    t.forward(90)
    t.penup()
    t.setheading(90)
    t.forward(110)
    t.pendown()
    t.setheading((-90))
    t.forward(115)
    turtle.done()
elif (choice1 == '2'):
    t = turtle.Pen()
    turtle.bgcolor('black')
    t.pencolor('white')
    t.goto(0, 0)
    t.circle(70)
    t.penup()
    t.goto(0, (-50))
    t.pendown()
    t.circle(120)
    t.penup()
    t.goto(0, (-100))
    t.pendown()
    t.circle(170)
    t.penup()
    t.goto(0, (-150))
    t.pendown()
    t.circle(220)
    t.penup()
    t.goto(0, (-200))
    t.pendown()
    t.circle(270)
    t.penup()
    t.goto(0, (-250))
    t.pendown()
    t.circle(320)
    t.penup()
    t.goto(0, (-300))
    t.pendown()
    t.circle(370)
    t.penup()
    t.goto(0, (-350))
    t.pendown()
    t.circle(420)
    t.penup()
    t.goto(0, 20)
    t.begin_fill()
    t.pendown()
    t.fillcolor("#CE0000")
    t.circle(50)
    t.end_fill()
    t.penup()
    t.goto(0, (-6))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#666666")
    t.circle(6)
    t.end_fill()
    t.penup()
    t.goto(0, (-60))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#ffff66")
    t.circle(8)
    t.end_fill()
    t.penup()
    t.goto(0, (-109))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#66cccc")
    t.circle(11)
    t.end_fill()
    t.penup()
    t.goto(0, (-170))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#ff6666")
    t.circle(15)
    t.end_fill()
    t.penup()
    t.goto(0, (-220))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#FFBB77")
    t.circle(20)
    t.end_fill()
    t.penup()
    t.goto(0, (-270))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#FFE66F")
    t.circle(22)
    t.end_fill()
    t.penup()
    t.goto(0, (-326))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#D2E9FF")
    t.circle(24)
    t.end_fill()
    t.penup()
    t.goto(0, (-385))
    t.begin_fill()
    t.pendown()
    t.fillcolor("#ADD8E6")
    t.circle(27)
    t.end_fill()
    turtle.done()
elif (choice1 == '3'):
    t = turtle.Pen()
    t.pensize(10)
    t.penup()
    t.goto((-200), (-250))
    t.setheading(0)
    t.pendown()
    t.forward(400)
    t.penup()
    t.goto((-100), (-250))
    t.setheading(90)
    t.pendown()
    t.forward(400)
    t.penup()
    t.goto(100, (-250))
    t.setheading(90)
    t.pendown()
    t.forward(400)
    t.penup()
    t.left(90)
    t.forward(200)
    t.pendown()
    t.right(120)
    t.forward(200)
    t.right(120)
    t.forward(200)
    t.penup()
    t.goto((-200), (-250))
    t.setheading(60)
    t.pendown()
    t.forward(200)
    t.penup()
    t.goto(200, (-250))
    t.setheading(120)
    t.pendown()
    t.forward(200)
    t.penup()
    t.goto((-183), (-220))
    t.setheading(0)
    t.pendown()
    t.forward(77)
    t.penup()
    t.goto(183, (-220))
    t.setheading(180)
    t.pendown()
    t.forward(77)
    t.penup()
    t.goto((-120), (-250))
    t.setheading((-135))
    t.pendown()
    t.forward(50)
    t.setheading(0)
    t.forward(310)
    t.penup()
    t.goto(120, (-250))
    t.setheading((-45))
    t.pendown()
    t.forward(50)
    t.penup()
    t.goto((-35), 50)
    t.pendown()
    t.circle(50)
    t.penup()
    t.goto((-50), (-250))
    t.setheading(90)
    t.pendown()
    t.forward(120)
    t.setheading(0)
    t.forward(100)
    t.setheading((-90))
    t.forward(120)
    t.penup()
    t.goto(20, (-190))
    t.pendown()
    t.circle(10)
    turtle.done()
else:
    print('那再见吧', '太可惜了', Name, '你痛失了几个亿')

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
Sherlock远星Sherlock远星

可以尝试简化代码哦~

点赞0


评论


Sherlock远星Sherlock远星

沙发沙发~

点赞0


评论


Sherlock远星Sherlock远星

也建议添加一些注释,像哪里哪里是用来绘制头部的啊,尾部的啊~

点赞0


评论