zoukankan      html  css  js  c++  java
  • Python少儿编程全集(一):一只小海龟(turtle库的使用)

    这是Python少儿编程全集系列课程第一课,一只小海龟(tutle库的使用)

    视频如下:

    课程内容如下:

    1.召唤小海龟,导入turtle及设置海龟图形

    import turtle
    turtle.shape("turtle")
    

    2.设置背景颜色为蓝色

    turtle.bgcolor("blue")

    3.让小海龟向前出发,移动距离为150px

    turtle.forward(150)

    4.让小海龟右转,右转角度为90°

    turtle.right(90)

    5.经过几轮直行与右转的组合,最终形成正方形,最后再将正方形上色

    turtle.fillcolor("yellow")
    turtle.begin_fill()
    

    结束
    turtle.end_fill()

    6.完整代码如下:

    import turtle
    turtle.shape("turtle")
    turtle.bgcolor("blue")
    turtle.fillcolor("yellow")
    turtle.begin_fill()
    #移动距离为150px
    turtle.forward(150)
    #右转角度为90°
    turtle.right(90)
    #移动距离为150px
    turtle.forward(150)
    #右转角度为90°
    turtle.right(90)
    #移动距离为150px
    turtle.forward(150)
    #右转角度为90°
    turtle.right(90)
    #移动距离为150px!
    turtle.forward(150)
    turtle.end_fill()
    

    留个作业(完成的回帖哦0.0):

    ![]()
    我是bigbigli!!! 更多内容请关注微信公众号:“大李日志”
  • 相关阅读:
    生信入门-爱课程上的华中农业大学
    PAT 1115 Counting Nodes in a BST[构建BST]
    PAT 1133 Splitting A Linked List[链表][简单]
    PAT 1037 Magic Coupon[dp]
    PAT 1033 To Fill or Not to Fill[dp]
    畅通工程续 HDU1874
    Free DIY Tour HDU1224
    六度分离 HDU1869
    Arbitrage HDU1217
    floyed算法
  • 原文地址:https://www.cnblogs.com/bigbigli/p/13714474.html
Copyright © 2011-2022 走看看