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

    1、画五角星

    import turtle
    turtle.color('yellow')
    turtle.fillcolor('yellow')
    turtle.bgcolor('red')
    
    turtle.begin_fill()
    
    for i in range(5):
        turtle.forward(100)
        turtle.right(144)
    
    turtle.end_fill()

    2、画同心圆

    import turtle
    turtle.color('yellow')
    turtle.fillcolor('red')
    turtle.bgcolor('black')
    
    def pgoto(x,y):
        turtle.up()
        turtle.goto(x,y)
        turtle.down()
    
    turtle.begin_fill()
    
    for i in range(10):
        pgoto(0,0-(20*i))
        turtle.circle(20*(i+1))
        turtle.write(10-i)
    
    turtle.end_fill()

    3、画太阳花

    import turtle
    turtle.color('yellow')
    turtle.fillcolor('red')
    turtle.bgcolor('black')
    
    turtle.begin_fill()
    
    while True:
        turtle.forward(200)
        turtle.left(170)
        if(abs(turtle.pos()))<1:
            break
    
    turtle.end_fill()

     

    4、画五个五角星

    import turtle
    turtle.color('yellow')
    turtle.fillcolor('yellow')
    turtle.bgcolor('red')
    j=-250
    k=-250
    
    def pgoto(x,y):
        turtle.up()
        turtle.goto(x,y)
        turtle.down()
    
    def drawwujiao(r):
        for i in range(5):
            turtle.forward(r)
            turtle.right(144)
    
    turtle.begin_fill()
    
    for i in range(4):
        pgoto(j+(i*150),k+(i*150))
        drawwujiao(100)
    
    turtle.end_fill()
    
    turtle.begin_fill()
    
    pgoto(-300,180)
    drawwujiao(250)
        
    turtle.end_fill()

     

  • 相关阅读:
    23种设计模式-桥接模式
    23种设计模式-单列模式
    23种设计模式-迭代器模式
    23种设计模式-组合模式
    23种设计模式-备忘录模式
    23种设计模式-适配器模式
    23种设计模式-状态模式
    SVN的安装和应用
    线程、线程池
    条形码
  • 原文地址:https://www.cnblogs.com/Naiky/p/7508572.html
Copyright © 2011-2022 走看看