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


    画五角星

    import turtle
    turtle.bgcolor('pink')
    turtle.color('purple')
    while True:
        turtle.forward(200)
        turtle.right(144)
        if(abs(turtle.pos()))<1:
            break
    

      

    画太阳花

    import turtle
    turtle.bgcolor('pink')
    turtle.color('purple')
    turtle.fillcolor('blue')
    
    turtle.begin_fill()
    while True:
        turtle.forward(200)
        turtle.left(140)
        if(abs(turtle.pos()))<1:
            break
    turtle.end_fill()
    done()
    

      

    画同心圆

    import turtle
    for i in range(5):
        turtle.up()
        turtle.goto(0,-20*(i+1))
        turtle.down()
        turtle.circle(20*(i+1))
    

      

     画五个角星

    import turtle
    turtle.setup(600,400,0,0)
    turtle.color("yellow")
    turtle.bgcolor('red')
    turtle.fillcolor('yellow')
    
    def hahagoto(x,y):
        turtle.up()
        turtle.goto(x,y)
        turtle.down()
    
    hahagoto(-250,100)
    
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(100)
        turtle.right(144)
    turtle.end_fill()
    
    hahagoto(-150,160)
    
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(40)
        turtle.right(144)
    turtle.end_fill()
    
    hahagoto(-115,120)
    
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(40)
        turtle.right(144)
    turtle.end_fill()
    
    hahagoto(-120,70)
    
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(40)
        turtle.right(144)
    turtle.end_fill()
    
    hahagoto(-150,25)
    
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(40)
        turtle.right(144)
    turtle.end_fill()
    

      

  • 相关阅读:
    绝对定位和浮动的区别和运用
    xhtml css 漏 整理
    网站自适应设备屏幕
    CSS 媒体查询 响应式
    js/jquery判断浏览器 & 停止加载
    回调函数之同步调用、回调、异步调用
    Flash生成HTML5动画方法
    在html页面中使用js变量
    BZOJ 4417 Luogu P3990 [SHOI2013]超级跳马 (DP、矩阵乘法)
    NOI2019游记
  • 原文地址:https://www.cnblogs.com/Sun584125503/p/7508476.html
Copyright © 2020-2023  润新知