Python turtle库之:如何画简单的无色金字塔?

文章目录

前言

大家好,我是BoBo仔。今天,我来教大家如何画一个3层金字塔

源码

源码如下:

import turtle as t
for s in range(1,4):
    t.forward(30)
    t.left(120)
t.setheading(240)
t.backward(30)
t.setheading(240)
for m in range(1,4):
    t.forward(60)
    t.left(120) 
t.setheading(240)
for l in range(1,4):
    t.forward(90)
    t.left(120)
t.hideturtle()
t.done()
2.1
import turtle as t
t.pensize(5)  
t.color("black", "yellow")  # 设置画笔颜色
t.begin_fill()  
t.circle(100)
t.end_fill()
#画眼睛(左眼)
t.penup()  
t.goto(-40, 120)  
t.pendown()
t.pensize(2)
t.color("black", "white")
t.begin_fill()
t.circle(12)
t.end_fill()
#画眼睛(右眼)
t.penup()
t.goto(40, 120)
t.pendown()
t.color("black", "white")
t.begin_fill()
t.circle(12)
t.end_fill()
#画嘴
t.penup()
t.goto(-40, 80)
t.pendown()
t.right(90)
t.pensize(3)
t.color("black")
t.circle(40, 180)
t.hideturtle()
t.done()
2.2
import turtle as t
t.circle(100)
t.goto(0,0)

t.penup()
t.sety(50)
t.pendown()
t.circle(50)


t.pencolor('red')
t.setheading(90)
t.forward(100)
t.pencolor('black')
t.setheading(180)
t.circle(50,90)
t.pencolor('red')
t.setheading(180)
t.backward(100)
t.done()
Markdown 3387 字数 232 行数 当前行 151, 当前列 9HTML 2744 字数 185 段落

你学会了吗?别忘了留下关注哟!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值