zoukankan      html  css  js  c++  java
  • turtle库基础练习

    1. 画一组同切圆
    2. 画一组同心圆
    3. 画一个五角星
    4. 画一个黄色实心五角星 

    #同心圆
    import turtle
    turtle.shape('turtle')
    turtle.circle(10)
    turtle.up()
    turtle.goto(0,-10)
    turtle.down()
    turtle.circle(20)
    turtle.up()
    turtle.goto(0,-20)
    turtle.down()
    turtle.circle(30)
    turtle.up()
    turtle.goto(0,-30)
    turtle.down()
    turtle.circle(40)
    #同切圆
    turtle.circle(10)
    turtle.circle(20)
    turtle.circle(30)
    turtle.circle(40)
    #五角星
    import turtle
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(36)
    turtle.right(19)
    turtle.forward(50)
    turtle.reset()
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)
    turtle.right(144)
    turtle.forward(50)

    #for循环五角星

    import turtle
    for i in range(5):
        turtle.forward(50)
        turtle.right(144)

    #黄色实心五角星

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

    #国旗

    import turtle
    turtle.bgcolor('red')
    turtle.color('yellow')


    turtle.begin_fill()
    turtle.up()
    turtle.goto(-220,180)
    for i in range(5):

        turtle.forward(50)
        turtle.right(144)
    turtle.end_fill()

    turtle.begin_fill()
    turtle.up()
    turtle.goto(-140,180)
    turtle.left(30)
    for i in range(5):
        turtle.forward(30)
        turtle.right(144)

    turtle.end_fill()

    turtle.begin_fill()
    turtle.up()
    turtle.goto(-145,140)
    for i in range(5):
        turtle.forward(30)
        turtle.right(144)
    turtle.end_fill()

    turtle.begin_fill()
    turtle.up()
    turtle.goto(-170,110)
    for i in range(5):
        turtle.forward(30)
        turtle.right(144)
    turtle.end_fill()

    turtle.begin_fill()
    turtle.up()
    turtle.goto(-150,220)
    for i in range(5):
        turtle.forward(30)
        turtle.right(144)
    turtle.end_fill()

  • 相关阅读:
    成功在C#和VB中将shp转换为CAD
    java 提取字符串中的数字
    java 通用文件下载 excel,pdf,word,jpg,exe,rar
    java org 写excel
    java 通用文件下载 excel,pdf,word,jpg
    重建MDB空间网格大小的工具
    redis5.0 Cluster集群搭建
    选中对象【WPF】自定义控件之依赖属性
    成员函数对象类的const和非const成员函数的重载
    设备注册Linux加载DTS设备节点的过程(以高通8974平台为例)
  • 原文地址:https://www.cnblogs.com/decadeyu/p/7493116.html
Copyright © 2011-2022 走看看