a.五角星
import turtle
turtle.color('yellow')
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
b.同心圆
import turtle
for i in range(5):
turtle.up()
turtle.goto(0,-20*(i+1))
turtle.down()
turtle.circle(20*(i+1))
c.太阳花
from turtle import*
speed(40)
color('red','yellow')
begin_fill()
while True:
forward(300)
left(179)
if(abs(pos()))<1:
break
end_fill()
done()
d.五个五角星
import turtle
turtle.setup(600,400,0,0)
turtle.color('yellow')
turtle.bgcolor('red')
turtle.fillcolor('yellow')
def my_goto(x,y):
turtle.up()
turtle.goto(x,y)
turtle.down()
def my_draw5(r):
turtle.begin_fill()
for i in range(5):
turtle.forward(r)
turtle.right(144)
turtle.end_fill()
my_goto(-360,190)
my_draw5(100)
my_goto(-155,240)
my_draw5(50)
my_goto(-90,165)
my_draw5(50)
my_goto(-75,85)
my_draw5(50)
my_goto(-120,50)
my_draw5(50)
e.画菱形太阳花
import turtle
def draw_center(brad):
brad.forward(125)
brad.right(45)
brad.forward(100)
brad.right(135)
def draw_flower():
window=turtle.Screen()
window.bgcolor('blue')
brad=turtle.Turtle()
brad.color('yellow')
brad.speed(20)
for i in range(1,18):
draw_center(brad)
draw_center(brad)
brad.left(20)
brad.right(70)
brad.forward(325)
window.exitonclick()
draw_flower()
turtle.hideturtle()