zoukankan      html  css  js  c++  java
  • 条件、循环、函数定义 练习

    1、画五角星

    import turtle
    >>> turtle.pencolor("red")
    >>> turtle.pensize(1)
    >>> turtle.fillcolor("yellow")
    >>> turtle.begin_fill()
    >>> for i in range(5):
    	turtle.forward(100)
    	turtle.right(144)
    
    	
    >>> turtle.end_fill()
    >>> turtle.hideturtle()
    >>> turtle.done()
    

      

    2、画同心圆

    import turtle
    for i in range(3):
    	turtle.circle(10*(i+1))
    	turtle.up()
    	turtle.goto(0,-10*(i+1))
    	turtle.down()
    
    	
    turtle.hideturtle()
    turtle.done()
    

      

    3、画太阳花

    from turtle import*
    color("red","yellow")
    begin_fill()
    while True:
        forward(200)
        left(170)
        if(abs(pos()))<1:
            break
    end_fill()
    done()
    

      

    4、画五个五角星

    import turtle
    turtle.setup(800,600,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(-350,180)
    my_draw5(150)
    
    
    my_goto(-175,250)
    turtle.left(50)
    my_draw5(50)
    
    my_goto(-100,173)
    turtle.left(44)
    my_draw5(50)
    
    my_goto(-70,80)
    turtle.left(50)
    my_draw5(50)
    
    my_goto(-130,50)
    turtle.left(50)
    my_draw5(50)
    
    turtle.hideturtle()
    turtle.done()
    

      

    5、画◇花瓣的太阳花

    import turtle
    
    turtle.speed("fastest")
    turtle.fillcolor("yellow")
    turtle.pencolor("red")
    turtle.begin_fill()
    def draw_art():
        for i in range(1,3):
            turtle.forward(150)
            turtle.right(45)
            turtle.forward(150)
            turtle.right(135)
    
    for i in range(1,37):
        draw_art()
        turtle.left(10)
    turtle.end_fill()
    turtle.forward(400)
    
    turtle.hideturtle()
    turtle.done()
    

      

  • 相关阅读:
    三级连动的下拉框(数据库版)吐血推荐
    行排菜单
    用AJAX制作天气预
    XmlHttp实战学习中....
    ASP+JS三级连动下拉框
    ASP连接11种数据库语法总结
    oa数据库设计
    RSS PUBData 把正常时间函数转成rss2.0的标准
    浮点数的表示和基本运算
    C#4.0新特性:可选参数,命名参数,Dynamic
  • 原文地址:https://www.cnblogs.com/0055sun/p/7517393.html
Copyright © 2011-2022 走看看