python画熊猫代码_用Python Turtle 画可爱的熊猫

1311c2ab033f471f9019e3c6aa1fb9ae

import turtle as t

# 设置初始画布和画笔

t.setup(width=1450, height=1450, startx=0, starty=0)

t.speed(0)

t.rt(-120)

t.up()

t.pensize(6)

t.goto(180, 150)

t.bgcolor('white')

t.title("My Panda")

t.down()

t.color('black')

#头轮廓

t.circle(190, 100)

t.fd(20)

for i in range(260):

t.fd(1)

t.lt(0.5)

for i in range(8):

t.fd(19)

t.lt(1)

for i in range(260):

t.fd(1)

t.lt(0.5)

t.up()

#身子轮廓

t.goto(-70, -16)

t.setheading(245)

t.down()

for i in range(35):

t.fd(1.5)

t.lt(0.5)

for i in range(5):

t.fd(1.5)

t.lt(0.0125)

for i in range(9):

t.fd(0.75)

t.lt(1.5)

for i in range(22):

t.fd(1)

t.lt(0.3)

for i in range(20):

t.fd(1)

t.lt(3)

for i in range(180):

t.fd(1)

t.lt(0.20)

for i in range(20):

t.fd(1)

t.lt(3)

for i in range(22):

t.fd(1)

t.lt(0.3)

for i in range(9):

t.fd(0.75)

t.lt(1.5)

for i in range(5):

t.fd(1.5)

t.lt(0.0125)

for i in range(25):

t.fd(1.5)

t.lt(0.5)

t.up()

#脚

#右脚

t.goto(-65, -119)

t.down()

t.begin_fill()

t.color('black')

t.setheading(280)

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import turtle # 设置绘制窗口的大小和背景颜色 turtle.setup(800, 600) turtle.bgcolor("white") # 定义笔颜色函数 def set_color(color1, color2): turtle.pencolor(color1) turtle.fillcolor(color2) # 绘制熊猫的头部 def draw_head(): turtle.penup() turtle.goto(0, -200) turtle.pendown() turtle.setheading(45) set_color("black", "white") turtle.begin_fill() turtle.circle(200, steps=4) turtle.end_fill() # 绘制熊猫的耳朵 def draw_ears(): turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.setheading(45) set_color("black", "black") turtle.begin_fill() turtle.circle(60, steps=4) turtle.end_fill() turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.setheading(135) turtle.begin_fill() turtle.circle(60, steps=4) turtle.end_fill() # 绘制熊猫的眼睛 def draw_eyes(): turtle.penup() turtle.goto(-50, 50) turtle.pendown() set_color("black", "black") turtle.begin_fill() turtle.circle(30) turtle.end_fill() turtle.penup() turtle.goto(50, 50) turtle.pendown() set_color("black", "black") turtle.begin_fill() turtle.circle(30) turtle.end_fill() # 绘制熊猫的鼻子 def draw_nose(): turtle.penup() turtle.goto(0, -20) turtle.pendown() set_color("black", "black") turtle.begin_fill() turtle.circle(20) turtle.end_fill() # 绘制熊猫的嘴巴 def draw_mouth(): turtle.penup() turtle.goto(-50, -60) turtle.pendown() set_color("black", "black") turtle.right(90) turtle.circle(50, 180) # 绘制熊猫的身体 def draw_body(): turtle.penup() turtle.goto(0, -200) turtle.pendown() set_color("black", "white") turtle.begin_fill() turtle.circle(200) turtle.end_fill() # 绘制熊猫的手 def draw_hands(): turtle.penup() turtle.goto(100, -250) turtle.pendown() set_color("black", "white") turtle.setheading(-30) turtle.begin_fill() turtle.circle(80, 120) turtle.left(60) turtle.circle(80, 120) turtle.end_fill() # 绘制熊猫的脚 def draw_feet(): turtle.penup() turtle.goto(-100, -250) turtle.pendown() set_color("black", "white") turtle.setheading(-150) turtle.begin_fill() turtle.circle(80, 120) turtle.left(60) turtle.circle(80, 120) turtle.end_fill() # 调用各个函数绘制熊猫 draw_head() draw_ears() draw_eyes() draw_nose() draw_mouth() draw_body() draw_hands() draw_feet() # 隐藏turtle.hideturtle() #

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值