while循环与for循环
import turtle turtle.setup(600,400,0,0) turtle.bgcolor('black') turtle.color('white') turtle.fillcolor('white') def mygoto(x,y): turtle.penup() turtle.goto(x,y) turtle.pendown() def draw5star(r): turtle.begin_fill() for i in range(5): turtle.forward(r) turtle.right(144) turtle.end_fill() mygoto(-250,100) draw5star(50) mygoto(-100,125) draw5star(20) mygoto(-50,100) draw5star(20) mygoto(-70,50) draw5star(20) mygoto(-100,0) draw5star(20) turtle.done()
import turtle while True: turtle.forward(100) turtle.right(68) if (abs(turtle.pos()))<1: break turtle.done()