标签:turtle def div ide hid abs 技术 com oca
1.画五角星
import turtle for i in range(5): turtle.forward(100) turtle.left(144) turtle.hideturtle()
2.画同心圆
import turtle for i in range(5): turtle.circle(20*(i+1)) turtle.up() turtle.goto(0,-20*(i+1)) turtle.down() turtle.hideturtle()
3.画太阳花
import turtle while True: turtle.forward(200) turtle.left(170) if(abs(turtle.pos()))<1: break turtle.hideturtle()
4.画五个五角星
import turtle def my5star(x): for i in range(5): turtle.forward(x) turtle.right(144) def mylocal(x,y): turtle.up() turtle.goto(x,y) turtle.down() mylocal(-380,250) my5star(100) mylocal(-270,290) my5star(25) mylocal(-240,260) my5star(25) mylocal(-240,230) my5star(25) mylocal(-270,200) my5star(25) turtle.hideturtle()
5.画◇花瓣的太阳花。
import turtle turtle.speed(‘fastest‘) def sunflower(): for i in range(2): turtle.forward(100) turtle.right(60) turtle.forward(100) turtle.right(120) for i in range(1,37): sunflower() turtle.right(10) turtle.right(90) turtle.forward(250) turtle.hideturtle()
标签:turtle def div ide hid abs 技术 com oca
原文地址:http://www.cnblogs.com/ffr0068/p/7516193.html