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

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

时间:2017-09-13 19:25:04      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:bre   begin   条件   end   down   分享   style   goto   pre   

import turtle 
#五角星
turtle.color(yellow)



turtle.begin_fill()
for i  in range(5):
    turtle.forward(100)
    turtle.right(144)
    turtle.end_fill()

技术分享

import turtle
#同心圆
def tongxinyuan(r):
    for i in range(5):
        turtle.penup()
        turtle.goto(0,-50*(i+1))
        turtle.pendown()
        turtle.circle(r*(i+1))




tongxinyuan(50)

技术分享

import turtle

#太阳花
turtle.bgcolor(black)
turtle.color(gray,white)
turtle.speed("fastest")
turtle.begin_fill()
while True:
    turtle.forward(250)
    turtle.left(155)
    if abs(turtle.pos())<1:
        break
turtle.end_fill()

turtle.done()

技术分享

import turtle

#五个五角星
turtle.bgcolor(red)
turtle.color(yellow)

#画一个五角星
def wujiaoxin1(x,y):
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(x)
        turtle.right(y)
    turtle.end_fill()

def wujiaoxin2(x,y):
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(x)
        turtle.left(y)
    turtle.end_fill()


#定义坐标
def zuobiao(x,y):
    turtle.up()
    turtle.goto(x,y)
    turtle.down()

    
zuobiao(-330,190)
wujiaoxin1(100,144)

zuobiao(-190,250)
wujiaoxin2(50,144)

zuobiao(-150,170)
wujiaoxin2(50,144)

zuobiao(-150,110)
wujiaoxin1(50,144)

zuobiao(-190,20)
wujiaoxin2(50,144)

技术分享

import turtle
turtle.bgcolor(black)
turtle.color(gray,black)
turtle.speed("fastest")


turtle.begin_fill()
for i in range(73):
    turtle.forward(150)
    turtle.left(45)
    turtle.forward(150)
    turtle.left(135)
    turtle.forward(150)
    turtle.left(45)
    turtle.forward(150)
    turtle.left(135)
    turtle.left(5)
turtle.end_fill()

技术分享

 

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

标签:bre   begin   条件   end   down   分享   style   goto   pre   

原文地址:http://www.cnblogs.com/wgd0069/p/7516401.html

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