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()

     

  • 相关阅读:
    python-day24(模块语法)
    python-day23(正则表达式,RE)
    python-day22(序列化)
    python-day21(模块初级)
    python-day20(继承)
    python-day19(约束和异常处理)
    python-day18(反射)
    延迟任务
    亚马逊服务器创建root用户
    sqlalchemy orm
  • 原文地址:https://www.cnblogs.com/Naiky/p/7508572.html
Copyright © 2011-2022 走看看