国庆节将至,今天在课上老师交给我们一个任务,那就是用Python创作出一个国旗来个祖国庆生,让我们来看看吧。
代码如下:
#National_Flag.py
import turtle
turtle.title("National_falg")
turtle.up() #起笔
turtle.goto(-200,200) #画笔从中心向x轴负方向移动200像素点,向y轴正方向移动200像素点
turtle.down() #落笔
turtle.begin_fill() #开始填充
turtle.fillcolor("red") #填充颜色为红色
turtle.pencolor("red") #画笔颜色为红色
for i in range(2): #设置循环为2
turtle.forward(280) #画笔前进280像素点
turtle.right(90) #向右转90度
turtle.forward(200) #画笔前进200像素点
turtle.right(90) #向右转90度
turtle.end_fill() #停止填充
turtle.up()
turtle.goto(-170,145)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.up()
turtle.goto(-100,180)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow&