首页 > 编程知识 正文

python海龟库代码(小海龟编程基本指令)

时间:2023-05-04 12:24:33 阅读:65055 作者:1061

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

视频如下:

课程内容如下。

1 .呼叫海龟,导入turtle,设置海龟图形

导入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 .完整的代码如下:

导入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 ) :

! ([ () ) ) )

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。