码迷,mamicode.com
首页 > 其他好文 > 详细

条件、循环、函数定义 练习

时间:2017-09-14 10:40:21      阅读:136      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!