python绘小结(2)

#例题1绘制一个四叶草

import turtle

turtle.color("green","green")

turtle.setheading(90)

turtle.begin_fill()

for i in range(4):

turtle.circle(-100,180)

turtle.left(90)

turtle.end_fill()

turtle.done()

#例题2绘制一个四角星

import turtle

turtle.color("yellow","yellow")

turtle.begin_fill()

for i in range(4):

turtle.circle(100,90)

turtle.right(180)

turtle.end_fill()

turtle.done()

#例题3绘制一个四叶花瓣

import turtle

turtle.color("pink","pink")

turtle.begin_fill()

turtle.circle(-100,90)

turtle.right(90)

turtle.circle(-100,90)

turtle.circle(100, 90)

turtle.right(90)

turtle.circle(-100, -90)

turtle.right(90)

turtle.circle(-100, 90)

turtle.right(90)

turtle.circle(-100, 90)

turtle.circle(100, 90)

turtle.right(90)

turtle.circle(-100, -90)

turtle.end_fill()

turtle.done()

#例题4输入一个数字,绘制以该数字为边数的正多边形

import turtle

a=int(turtle.textinput("绘制正多边形","请输入边数:"))

turtle.circle(100,360,a)

turtle.done()