无我

在小学尝试以Python为载体培养学生计算思维

Python海龟绘图常用指令整理

首先使用 import turtle 导入turtle绘图模块,之后就可以使用模块提供的指令了。下面整理了一些常用指令:



练习1:




代码:

#导入海龟作图模块,改名为t

import turtle as t

t.color("blue")

t.speed(0)

#循环8次

for i in range(8):

    t.circle(200)

    t.rt(360/8)

t.ht()


练习2:


代码:

#导入海龟作图模块,改名为t

import turtle as t

t.color("blue")

t.dot(100)

t.color("red")

t.speed(0)

#循环10次

for i in range(10):

    t.fd(200)

    t.dot(60)

    t.bk(200)

    t.rt(360/10)

t.ht()


评论
热度 ( 1 )

© 无我 | Powered by LOFTER