1.画一组同切圆
>>> import turtle >>> turtle.circle(10) >>> turtle.circle(20) >>> turtle.circle(30)
2.画一组同心圆
import turtle for i in range(5): turtle.up() turtle.goto(0,-25*(i+1)) turtle.down() turtle.circle(25*(i+1))
3.画一个五角星
>>> import turtle >>> turtle.color('yellow') >>> turtle.bgcolor('red') >>> turtle.hideturtle() >>> turtle.beginfill() Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> turtle.beginfill() AttributeError: module 'turtle' has no attribute 'beginfill' >>> turtle.begin_fill() >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.end_fill()
4.画一个黄色实心五角星
>>> import turtle >>> turtle.color('yellow') >>> turtle.bgcolor('red') >>> turtle.hideturtle() >>> turtle.beginfill() Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> turtle.beginfill() AttributeError: module 'turtle' has no attribute 'beginfill' >>> turtle.begin_fill() >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.right(144) >>> turtle.forward(99) >>> turtle.end_fill()
5.画左上角的五颗五角星
import turtle turtle.setup(600,400,0,0) turtle.color('yellow') turtle.bgcolor('red') turtle.fillcolor('yellow') def mygoto(x,y): turtle.up() turtle.goto(x,y) turtle.down() mygoto(-250,75) turtle.begin_fill() for i in range(5): turtle.forward(100) turtle.right(144) turtle.end_fill() mygoto(-100,150) turtle.begin_fill() for i in range(5): turtle.forward(50) turtle.right(144) turtle.end_fill() mygoto(-80,80) turtle.begin_fill() for i in range(5): turtle.forward(50) turtle.right(144) turtle.end_fill() mygoto(-70,20) turtle.begin_fill() for i in range(5): turtle.forward(50) turtle.right(144) turtle.end_fill() mygoto(-80,-40) turtle.begin_fill() for i in range(5): turtle.forward(50) turtle.right(144) turtle.end_fill()