turtle库基础练习
1.画一组同切圆
>>> import turtle >>> turtle.circle(10) >>> turtle.circle(20) >>> turtle.circle(30) >>> turtle.circle(40) >>> turtle.circle(50)
2.画一组同心圆
turtle.up()
turtle.goto(50,50)
turtle.down()
turtle.circle(10)
turtle.up()
turtle.goto(50,30)
turtle.down()
turtle.circle(30)
turtle.up()
turtle.goto(50,10)
turtle.down()
turtle.circle(50)
![]()
3.画一个五角星
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.right(144)

4.画一个黄色实心五角星
turtle.shape("turtle") turtle.fillcolor('yellow') turtle.color("yellow") 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.right(144) turtle.end_fill() turtle.hideturtle()
5.画左上角的五颗五角星
import turtle turtle.shape("turtle") turtle.bgcolor("red") turtle.fillcolor('yellow') turtle.color("yellow") turtle.begin_fill() turtle.up() turtle.goto(-200,200) turtle.forward(75) turtle.right(144) turtle.forward(75) turtle.right(144) turtle.forward(75) turtle.right(144) turtle.forward(75) turtle.right(144) turtle.forward(75) turtle.right(144) turtle.end_fill() turtle.hideturtle() turtle.fillcolor('yellow') turtle.color("yellow") turtle.begin_fill() turtle.up() turtle.goto(-110,270) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.end_fill() turtle.hideturtle() turtle.fillcolor('yellow') turtle.color("yellow") turtle.begin_fill() turtle.up() turtle.goto(-70,220) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.end_fill() turtle.hideturtle() turtle.fillcolor('yellow') turtle.color("yellow") turtle.begin_fill() turtle.up() turtle.goto(-85,165) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.end_fill() turtle.hideturtle() turtle.fillcolor('yellow') turtle.color("yellow") turtle.begin_fill() turtle.up() turtle.goto(-130,120) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.forward(45) turtle.right(144) turtle.end_fill() turtle.hideturtle()
turtle.done()




浙公网安备 33010602011771号