前言
大家好,我是BoBo仔。今天,我来教大家如何画一个3层金字塔
源码
源码如下:
import turtle as t
for s in range(1,4):
t.forward(30)
t.left(120)
t.setheading(240)
t.backward(30)
t.setheading(240)
for m in range(1,4):
t.forward(60)
t.left(120)
t.setheading(240)
for l in range(1,4):
t.forward(90)
t.left(120)
t.hideturtle()
t.done()
2.1
import turtle as t
t.pensize(5)
t.color("black", "yellow") # 设置画笔颜色
t.begin_fill()
t.circle(100)
t.end_fill()
#画眼睛(左眼)
t.penup()
t.goto(-40, 120)
t.pendown()
t.pensize(2)
t.color("black", "white")
t.begin_fill()
t.circle(12)
t.end_fill()
#画眼睛(右眼)
t.penup()
t.goto(40, 120)
t.pendown()
t.color("black", "white")
t.begin_fill()
t.circle(12)
t.end_fill()
#画嘴
t.penup()
t.goto(-40, 80)
t.pendown()
t.right(90)
t.pensize(3)
t.color("black")
t.circle(40, 180)
t.hideturtle()
t.done()
2.2
import turtle as t
t.circle(100)
t.goto(0,0)
t.penup()
t.sety(50)
t.pendown()
t.circle(50)
t.pencolor('red')
t.setheading(90)
t.forward(100)
t.pencolor('black')
t.setheading(180)
t.circle(50,90)
t.pencolor('red')
t.setheading(180)
t.backward(100)
t.done()
Markdown 3387 字数 232 行数 当前行 151, 当前列 9HTML 2744 字数 185 段落
你学会了吗?别忘了留下关注哟!