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


    1.画五角星

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

    2.画同心圆

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

    3.画太阳花

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

    4.画五个五角星

    import turtle
    turtle.color('yellow')
    turtle.fillcolor('yellow')
    turtle.bgcolor('red')
    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(-700,250)
    my_draw5(100)
    
    my_goto(-520,350)
    my_draw5(30)
    
    my_goto(-450,280)
    my_draw5(30)
    
    my_goto(-450,200)
    my_draw5(30)
    
    my_goto(-520,120)
    my_draw5(30)

    5.画◇花瓣的太阳花。

    import turtle
    
    def draw_diamond(brad):
        brad.forward(100)
        brad.right(45)
        brad.forward(100)
        brad.right(135)
    
    def draw_art():
        window=turtle.Screen()
        window.bgcolor('black')
    
        brad=turtle.Turtle()
        brad.shape('turtle')
        brad.color('yellow')
        brad.speed('fastest')
        for i in range(1,37):
            draw_diamond(brad)
            draw_diamond(brad)
            brad.left(10)
    
        brad.right(90)
        brad.forward(300)
        brad.hideturtle()
        window.exitionclick()
    
    draw_art()

  • 相关阅读:
    VS2017使用inet_ntoa()产生错误的解决方法
    ET框架:如何运行ET-Demo
    ProtoBuf入门
    AssetBundle入门
    UML图写法
    Visual Studio小技巧-引用项目外部的类
    UnityECS(一)UnityECS学习资料
    关于如何利用MySQL Workbench导入Excel表格
    SublimeText3插件安装(未完更新)
    Unity中Animator的2DSprite动画控制与使用
  • 原文地址:https://www.cnblogs.com/hxl316/p/7515274.html
Copyright © 2020-2023  润新知