用户:钢铁龘齾查看:0 回复:0 评论:0 创建时间:2019-11-16T11:49:46
【作品展示】

【作品介绍】
很可爱的小台灯哦~颜色还是随机的!
【作品源代码】
import turtle
import random
t = turtle.Pen()
t.speed(0)
t.hideturtle()
colors = ["red","yellow","blue","green","orange","purple","pink","white","brown","magenta","cyan"]
q = random.choice(colors)
w = random.choice(colors)
e = random.choice(colors)
def first(color):
t.penup()
t.right(90)
t.forward(100)
t.setheading(0)
t.backward(50)
t.pendown()
t.fillcolor(color)
t.begin_fill()
t.pencolor(color)
for x in range(2):
t.forward(100)
t.left(90)
t.forward(5)
t.left(90)
t.end_fill()
def second(color_b):
t.penup()
t.forward(50)
t.left(90)
t.forward(5)
t.left(90)
t.forward(2)
t.pendown()
t.fillcolor(color_b)
t.begin_fill()
t.setheading(90)
t.pencolor(color_b)
t.forward(100)
for c in range(45):
t.forward(2)
t.left(2)
t.right(90)
t.forward(4)
t.right(90)
for v in range(45):
t.forward(2)
t.right(2)
t.forward(106)
t.right(90)
t.forward(4)
t.end_fill()
def third(color_c):
t.penup()
t.right(90)
t.forward(100)
for b in range(45):
t.forward(2)
t.left(2)
t.pendown()
t.pencolor(color_c)
t.fillcolor(color_c)
t.begin_fill()
t.right(90)
for n in range(30):
t.forward(2)
t.left(3)
t.left(90)
t.forward(60)
t.left(90)
for n in range(30):
t.forward(2)
t.left(3)
t.end_fill()
def fourth():
t.penup()
t.left(90)
t.forward(39)
t.pendown()
t.fillcolor("white")
t.begin_fill()
t.pencolor("white")
for m in range(90):
t.forward(0.3)
t.left(2)
t.end_fill()
def draw():
turtle.bgcolor("black")
first(q)
second(w)
third(e)
fourth()
turtle.bgcolor("gray")
draw()
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn