综合练习:画一面五星红旗。
# 首先导入turtle库 import turtle # 定义一个函数,可以画五角星 def picture(x1,y1,x,y): turtle.up() turtle.goto(x1, y1) turtle.down() #用于填充颜色 turtle.begin_fill() turtle.fillcolor("yellow") for i in range(5): turtle.forward(x) turtle.left(y) turtle.end_fill() # 速度为2 turtle.speed(2) # 背景红色 turtle.bgcolor("red") # 画笔颜色 turtle.color("yellow") picture(-300,150,150,144) picture(-120,275,60,144) picture(-50,190,60,144) picture(-50,90,60,144) picture(-120,5,60,144) turtle.done()
效果显示: