用户:
伶俐的玛洛斯tU0G查看:0 回复:0 评论:0 创建时间:2021-05-16T14:28:17
【作品展示】

【作品介绍】
太阳系
【作品源代码】
import turtle
import random
screen = turtle.Screen()
mypen = turtle.Pen()
mypen.speed(0)
# 行星轨道
mypen.penup()
mypen.goto(0, 0)
mypen.pendown()
e = 1600
s = 0
while s < 8:
mypen.pencolor("white")
mypen.dot(e)
mypen.pencolor("black")
mypen.dot(e - 2)
e = e - 160
s = s + 1
# 星空
turtle.bgcolor("black")
mypen.pencolor("white")
a = 0
while a < 300:
x = random.randint(-900, 900)
y = random.randint(-500, 500)
z = random.randint(1, 10)
mypen.penup()
mypen.goto(x, y)
mypen.pendown()
mypen.dot(z)
a = a + 1
# 星球
colors = ['red2', 'darkgoldenrod', 'gold', 'aqua', 'brown','goldenrod', 'lemonchiffon', 'deepskyblue', 'dodgerblue']
wa = [200,15,20,25,30,70,60,50,40]
ws = [0,240,320,400,480,560,喵0,720,800]
wz = [-40,230,310,390,470,550,630,710,790]
wd = [-150,-35,-35,-35,-35,-70,-60,-50,-40]
we = ['太阳','水星','金星','地球','火星','木星','土星','天王星','海王星']
wr = [40,10,10,15,15,20,20,15,15]
b = 0
while b < 9:
mypen.penup()
mypen.goto(ws[b], 0)
mypen.pendown()
color = screen.textinput("输入颜色", "请输入一个英文颜色")
mypen.pencolor(color)
mypen.dot(wa[b])
mypen.penup()
mypen.goto(wz[b], wd[b])
mypen.pendown()
mypen.pencolor('skyblue')
mypen.write(we[b], font=("楷体", wr[b]))
b += 1
mypen.hideturtle()
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn