python学习之Turtle 4

继续学习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)

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值