Python -- 大作业 — 使用turtle库画皮卡丘

使用python的turtle库画皮卡丘

一、使用环境

在这里,我使用的是python 3.8.5版本的IDLE(也可以使用其他3.0以上版本,PyCharm也是可以的)。

二、内容介绍
1.主要方法介绍

seth:设置朝向;
fd:前进;
circle:画圆;
fillcolor:填充颜色;
pensize:画笔粗细;
speed:速度;
hideturtle:隐藏海龟;
screensize:设置屏幕大小;
begin_fill:开始填充;
end_fill:结束填充;
penup:画笔抬起;
pendown:画笔落下。

2.导入turtle库
import turtle
3.背景部分代码
#背景色
t
  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,我可以为您展示如何使用PythonTurtle画皮丘。 下面是绘制皮丘的Python代码: ```python import turtle # 创建一个新窗口 win = turtle.Screen() win.bgcolor("white") # 画布的大小 win.setup(width=600, height=600) # 将画笔移到屏幕中央,准备画脸 face = turtle.Turtle() face.color("black") face.fillcolor("yellow") face.penup() face.goto(0, -100) face.pendown() face.begin_fill() face.circle(200) face.end_fill() # 画左耳 left_ear = turtle.Turtle() left_ear.color("black") left_ear.fillcolor("black") left_ear.penup() left_ear.goto(-150, 180) left_ear.pendown() left_ear.begin_fill() left_ear.right(135) left_ear.circle(100, -90) left_ear.left(90) left_ear.circle(100, -45) left_ear.end_fill() # 画右耳 right_ear = turtle.Turtle() right_ear.color("black") right_ear.fillcolor("black") right_ear.penup() right_ear.goto(150, 180) right_ear.pendown() right_ear.begin_fill() right_ear.left(135) right_ear.circle(-100, -90) right_ear.right(90) right_ear.circle(-100, -45) right_ear.end_fill() # 画左眼 left_eye = turtle.Turtle() left_eye.color("black") left_eye.fillcolor("white") left_eye.penup() left_eye.goto(-80, 50) left_eye.pendown() left_eye.begin_fill() left_eye.circle(40) left_eye.end_fill() # 画右眼 right_eye = turtle.Turtle() right_eye.color("black") right_eye.fillcolor("white") right_eye.penup() right_eye.goto(80, 50) right_eye.pendown() right_eye.begin_fill() right_eye.circle(40) right_eye.end_fill() # 左眼珠 left_pupil = turtle.Turtle() left_pupil.color("black") left_pupil.fillcolor("black") left_pupil.penup() left_pupil.goto(-80, 20) left_pupil.pendown() left_pupil.begin_fill() left_pupil.circle(20) left_pupil.end_fill() # 画右眼珠 right_pupil = turtle.Turtle() right_pupil.color("black") right_pupil.fillcolor("black") right_pupil.penup() right_pupil.goto(80, 20) right_pupil.pendown() right_pupil.begin_fill() right_pupil.circle(20) right_pupil.end_fill() # 画鼻子 nose = turtle.Turtle() nose.color("black") nose.fillcolor("black") nose.penup() nose.goto(0, 60) nose.pendown() nose.begin_fill() nose.circle(30) nose.end_fill() # 画嘴巴 mouth = turtle.Turtle() mouth.color("black") mouth.penup() mouth.goto(-100, -40) mouth.pendown() mouth.right(90) mouth.circle(100, 180) # 使窗口保持打开状态 turtle.done() ``` 运行上述代码后,您可以在Turtle窗口中看到绘制的皮丘。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

衍生星球

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值