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

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

时间:2017-09-13 20:19:10      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:http   分享   war   span   技术   end   port   circle   logs   

  1. 画五角星
  2. import turtle
    for i in range(5):
        turtle.forward(200)
        turtle.right(144)

    技术分享

     

  3. 画同心圆
  4. import turtle
    for i in range(5):
        turtle.circle(20*(1+i))
        turtle.up()
        turtle.goto(0,-20*(1+i))
        turtle.down()
    turtle.done()

    技术分享

     

  5. 画太阳花
  6. import turtle
    from turtle import *
    turtle.color(‘red‘,‘yellow‘)
    turtle.begin_fill()
    while True:
        turtle.speed(10)
        turtle.forward(200)
        turtle.left(170)
        if (abs(pos()))<1:
            break
    turtle.end_fill()
    turtle.done()

    技术分享

     

  7. 画五个五角星
  8. import turtle
    turtle.fillcolor(red)
    turtle.speed(10)
    
    def my_goto(x,y):
        turtle.up()
        turtle.goto(x,y)
        turtle.down()
    def my_cd(s):
        turtle.forward(s)
        turtle.left(90)
    def my_draw5(r):
        turtle.begin_fill()
        for i in range(5):
            turtle.forward(r)
            turtle.right(144)
        turtle.end_fill()
    
    
        
    #国旗红底
    turtle.begin_fill()
    my_goto(-270,-180)
    my_cd(550)
    my_cd(330)
    my_cd(550)
    my_cd(330)
    turtle.end_fill()
    turtle.fillcolor(yellow)
    turtle.color(yellow)
    my_goto(-195,99)
    my_draw5(90)
    
    turtle.left(30)
    my_goto(-75,130)
    my_draw5(30)
    
    
    my_goto(-45,100)
    my_draw5(30)
    
    turtle.right(30)
    my_goto(-45,60)
    my_draw5(30)
    
    turtle.right(20)
    my_goto(-75,21)
    my_draw5(30)
    turtle.done()

    技术分享

     

  9. 画◇花瓣的太阳花
  10. import turtle
    turtle.speed(10)
    turtle.bgcolor(blue)
    turtle.fillcolor(red)
    def my_draw(s):
        turtle.begin_fill()
        turtle.forward(s)
        turtle.right(45)
        turtle.forward(100)
        turtle.right(135)
        turtle.forward(s)
        turtle.right(45)
        turtle.forward(100)
        turtle.right(135)
        turtle.end_fill()
    
    for i in range(1,37):
        my_draw(100)
        turtle.left(10)
    
    turtle.right(90)
    turtle.forward(300)
    turtle.done()

    技术分享

     

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

标签:http   分享   war   span   技术   end   port   circle   logs   

原文地址:http://www.cnblogs.com/Sjkq1/p/7516723.html

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