Appearance
带你走进编程世界II
复习回顾
复习一下上次课我们所学的画图函数.
思考题
我们上次画了那里图形?
- 一条直线
- 正方形
- 三角形
- 圆形
- 爱心
五角星
五角星是指一种有五只尖角、并以五条直线画成的星星图形。英文“五角星”(pentagram)一词出于希腊语,原意大概是“五条直线的”或“五条线”。中文“五角星”的意义则显而易见,指有五只角的星形。然而,中文“五角星”不一定指“标准”五角星。中文“五角星”一词有时亦泛指所有有五只角的星形物。

特性
- 5条边长度都相等
- 5个角的角度都相等, 每个角都是36度
- 内角各为180度

代码
py
from turtle import *
speed(1)
color("red")
begin_fill()
for _ in range(5):
forward(100)
left(72)
forward(100)
right(144)
end_fill()
hideturtle()
done()美国队长盾牌

代码
py
from turtle import *
#1、先将画笔往下移动200步,以使得图形能够完整呈现
penup() #抬笔
goto(0,-200) #移动到指定为止
pendown() #落笔
#2、画第一个圆形
color("red") #设置第一个图形的颜色
speed(0) #设置画笔的速度
begin_fill() #开始填充
circle(200) #画出第一个圆
end_fill() #结束填充
#3、画第二个圆形
goto(0,-160)
color("light grey")
begin_fill()
circle(160)
end_fill()
#4、画第三个圆形
goto(0,-120)
color("red")
begin_fill()
circle(120)
end_fill()
#5、画第四个圆形
goto(0,-90)
color("blue")
begin_fill()
circle(90)
end_fill()
#6、画五角星
goto(-85,27) #先移动到指定为止(手动调整的位置)
color("light grey") #设置五角星的颜色
begin_fill()
for i in range(5):
forward(65)
left(72)
forward(65)
right(144)
end_fill()
hideturtle()
done()彩虹

代码
py
from turtle import *
line=["orange","yellow","green","cyan","blue","purple"]
penup()
goto(-240,-180)
pendown()
color("red")
pensize(30)
left(90)
circle(-250,180)
a = -210
b = -220
for i in line:
penup()
color(i)
goto(a,-180)
a += 30 # a = b + 3
pendown()
left(180)
circle(b,180)
b += 30 # b = b + 3
done()