turtle库基础练习

  1. 画一组同切圆
  2. 画一组同心圆
  3. 画一个五角星
  4. 画一个黄色实心五角星 

 

#同心圆
import turtle
turtle.shape('turtle')
turtle.circle(10)
turtle.up()
turtle.goto(0,-10)
turtle.down()
turtle.circle(20)
turtle.up()
turtle.goto(0,-20)
turtle.down()
turtle.circle(30)
turtle.up()
turtle.goto(0,-30)
turtle.down()
turtle.circle(40)
#同切圆
turtle.circle(10)
turtle.circle(20)
turtle.circle(30)
turtle.circle(40)
#五角星
import turtle
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(36)
turtle.right(19)
turtle.forward(50)
turtle.reset()
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)

#for循环五角星

import turtle
for i in range(5):
    turtle.forward(50)
    turtle.right(144)

 

#黄色实心五角星

 

import turtle
turtle.bgcolor('red')
turtle.color('yellow')
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

 

#国旗

import turtle
turtle.bgcolor('red')
turtle.color('yellow')


turtle.begin_fill()
turtle.up()
turtle.goto(-220,180)
for i in range(5):

    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

turtle.begin_fill()
turtle.up()
turtle.goto(-140,180)
turtle.left(30)
for i in range(5):
    turtle.forward(30)
    turtle.right(144)

turtle.end_fill()

turtle.begin_fill()
turtle.up()
turtle.goto(-145,140)
for i in range(5):
    turtle.forward(30)
    turtle.right(144)
turtle.end_fill()

turtle.begin_fill()
turtle.up()
turtle.goto(-170,110)
for i in range(5):
    turtle.forward(30)
    turtle.right(144)
turtle.end_fill()

turtle.begin_fill()
turtle.up()
turtle.goto(-150,220)
for i in range(5):
    turtle.forward(30)
    turtle.right(144)
turtle.end_fill()

posted on 2017-09-08 09:51  046余博智  阅读(343)  评论(0编辑  收藏  举报

导航