标签:setup 函数定义 bsp set fill 菱形 logs flow bre
太阳花:
import turtle turtle.bgcolor(‘red‘,‘green‘) while True: turtle.forward(200) turtle.left(170) if(abs(turtle.pos()))<1: break
五个五角星
import turtle turtle.setup(600,400,0,0) turtle.color("yellow") turtle.bgcolor(‘red‘) turtle.fillcolor("yellow") def my_goto(x,y): turtle.up() turtle.goto(x,y) turtle.down() def my_draw5(r): turtle.begin_fill() for i in range(5): turtle.forward(r) turtle.right(144) turtle.end_fill() my_goto(-250,75) my_draw5(100) my_goto(-100,150) my_draw5(50) my_goto(-80,100) my_draw5(50) my_goto(-80,50) my_draw5(50) my_goto(-100,0) my_draw5(50)
画一个五角星
import turtle turtle.color(‘yellow‘) turtle.begin_fill() for i in range(5): turtle.forward(100) turtle.right(144) turtle.end_fill()
同心圆
import turtle for i in range(5): turtle.up() turtle.goto(0,-20*(i+1)) turtle.down() turtle.circle(20*(i+1))
画菱形太阳花
import turtle def draw_center(brad): brad.forward(125) brad.right(45) brad.forward(100) brad.right(135) def draw_flower(): window=turtle.Screen() window.bgcolor(‘blue‘) brad=turtle.Turtle() brad.color(‘yellow‘) brad.speed(20) for i in range(1,18): draw_center(brad) draw_center(brad) brad.left(20) brad.right(70) brad.forward(325) window.exitonclick() draw_flower() turtle.hideturtle()
标签:setup 函数定义 bsp set fill 菱形 logs flow bre
原文地址:http://www.cnblogs.com/yeyuanchao/p/7515427.html