标签:shape screen sha exit set code .sh pos for
from turtle import * fillcolor("red") begin_fill() for i in range(5): up() goto(0,-20*i) down() circle(20*i) end_fill()
一、同心圆
二、太阳花
from turtle import * color(‘red‘,‘yellow‘) begin_fill() while True: forward(200) right(150) if abs(pos())<1: break end_fill() done()
三、五星红旗
from turtle import * setup(640,440,0,0) color("yellow") bgcolor("red") fillcolor("yellow") def llf_goto(x,y): up() goto(x,y) down() def llf_draw(r): begin_fill() for i in range(5): forward(r) right(144) end_fill() llf_goto(-286,132) llf_draw(130) llf_goto(-132,180) llf_draw(50) llf_goto(-88,132) llf_draw(50) llf_goto(-88,72) llf_draw(50) llf_goto(-132,22) llf_draw(50)
四、画菱形花
import turtle def draw_1(llf): llf.forward(100) llf.right(45) llf.forward(100) llf.right(135) def draw_2(): window=turtle.Screen() window.bgcolor("blue") llf=turtle.Turtle() llf.shape("turtle") llf.color("orange") llf.speed("fastest") for i in range(1,37): draw_1(llf) draw_1(llf) llf.left(10) llf.right(90) llf.forward(155) llf.color(‘green‘) llf.forward(145) window.exitonclick() draw_2()
标签:shape screen sha exit set code .sh pos for
原文地址:http://www.cnblogs.com/kinoko/p/7684982.html