继续学习turtle
参考书目 趣学Python编程——Python for kids
小汽车
0小汽车
#车身主体
>>> t.reset()
>>> t.color(1,0,0) #颜色设置(RGB)
>>> t.begin_fill() #充填颜色begin
>>> t.forward(100)
>>> t.left(90)
>>> t.forward(20)
>>> t.left(90)
>>> t.forward(20)
>>> t.right(90)
>>> t.forward(20)
>>> t.left(90)
>>> t.forward(60)
>>> t.left(90)
>>> t.forward(20)
>>> t.right(90)
>>> t.forward(20)
>>> t.right(90)
>>> t.right(180)
>>> t.forward(20)
>>> t.end_fill() #充填颜色end
#大轮子
>>> t.color(0,0,0) #颜色设置(RGB)
>>> t.up()
>>> t.forward(10)
>>> t.down()
>>> t.begin_fill() #充填颜色begin
>>> t.circle(20) #画圆r = 20
>>> t.end_fill() #充填颜色end
#小轮子
>>> t.setheading(0) #设置画笔的朝向,画笔默认朝向为正右方
>>> t.up()
>>> t.forward(90)
>>> t.right(90)
>>> t.forward(10)
>>> t.setheading(0) #设置画笔的朝向,画笔默认朝向为正右方
>>> t.begin_fill()
>>> t.down()
>>> t.circle(10)
>>> t.end_fill()
圆圆圆
>>> t.reset()
# 画圆函数
>>> def mycircle(red, green, blue):
t.color(red, green, blue)
t.begin_fill()
t.circle(50)
t.end_fill()
>>> mycircle(0,1,0)
>>> mycircle(1,0,0)
>>> mycircle(0,0,1)
画方块
>>> t.reset()
>>> def mysquare(size):
for x in range(1,5):
t.forward(size)
t.left(90)
>>> mysquare(25)
>>> mysquare(50)
>>> mysquare(75)
>>> mysquare(100)
>>> mysquare(125)
>>> mysquare(150)