turtle库基础练习

1、画一组同切圆

>>> import turtle
>>> turtle.circle(10)
>>> turtle.circle(20)
>>> turtle.circle(30)
>>> turtle.circle(40)

 

2、画一组同心圆

import turtle

turtle.hideturtle()

turtle.up()
turtle.goto(0,-10)
turtle.down()
turtle.circle(10)
turtle.up()
turtle.goto(0,-20)
turtle.down()
turtle.circle(20)
turtle.up()
turtle.goto(0,-30)
turtle.down()
turtle.circle(30)

 

3、画一个五角星

import turtle

turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)

 

4、画一个黄色实心五角星

import turtle

turtle.color('yellow')
turtle.fillcolor('yellow')

turtle.begin_fill()
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.right(144)
turtle.forward(200)
turtle.end_fill()

turtle.hideturtle()

 

5、画左上角的五颗五角星

import turtle

turtle.speed(10)
turtle.color('yellow')
turtle.bgcolor('red')
turtle.fillcolor('yellow')

turtle.up()
turtle.goto(-300,150)
turtle.down()

turtle.begin_fill()
turtle.forward(120)
turtle.right(144)
turtle.forward(120)
turtle.right(144)
turtle.forward(120)
turtle.right(144)
turtle.forward(120)
turtle.right(144)
turtle.forward(120)
turtle.end_fill()

turtle.up()
turtle.goto(-80,230)
turtle.down()

turtle.begin_fill()
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)
turtle.end_fill()

turtle.up()
turtle.goto(-75,200)
turtle.down()

turtle.begin_fill()
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)
turtle.end_fill()

turtle.up()
turtle.goto(-80,80)
turtle.down()

turtle.begin_fill()
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)
turtle.end_fill()

turtle.up()
turtle.goto(-90,40)
turtle.down()

turtle.begin_fill()
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)
turtle.end_fill()

 

posted @ 2017-09-12 13:07  011赖颖璇  阅读(210)  评论(0)    收藏  举报