标签:五个 raw logs http bsp blog 技术分享 循环 分享
画五角星
import turtle turtle.color(‘red‘) turtle.fillcolor(‘red‘) turtle.begin_fill() for i in range(5): turtle.forward(100) turtle.right(144) turtle.end_fill() turtle.hideturtle()
结果如图:
画同心圆
import turtle for i in range(5): turtle.up() turtle.goto(0,-20*(i+1)) turtle.down() turtle.circle(20*(i+1)) turtle.hideturtle()
结果如图:
画太阳花
import turtle turtle.color(‘purple‘) turtle.fillcolor(‘red‘) turtle.begin_fill() while True: turtle.forward(200) turtle.left(170) if(abs(turtle.pos()))<1: break turtle.end_fill() turtle.hideturtle()
结果如图:
画五个五角星
import turtle turtle.bgcolor(‘red‘) turtle.color(‘yellow‘) turtle.fillcolor(‘yellow‘) def sj_goto(x,y): turtle.up() turtle.goto(x,y) turtle.down() def sj_draw(r): turtle.begin_fill() for i in range(5): turtle.forward(r) turtle.right(144) turtle.end_fill() sj_goto(-350,200) sj_draw(100) sj_goto(-180,280) sj_draw(50) sj_goto(-125,225) sj_draw(50) sj_goto(-125,150) sj_draw(50) sj_goto(-175,85) sj_draw(50)
turtle.hideturtle()
结果如图:
画◇花瓣的太阳花。
import turtle turtle.color(‘red‘) turtle.fillcolor(‘purple‘) turtle.begin_fill() for i in range(1,19): for i in range(1,3): turtle.forward(100) turtle.right(45) turtle.forward(100) turtle.right(135) turtle.left(20) turtle.end_fill() turtle.right(90) turtle.forward(400)
结果如图:
标签:五个 raw logs http bsp blog 技术分享 循环 分享
原文地址:http://www.cnblogs.com/arashinoj/p/7515330.html