使用Python画出小人发射爱心的代码
作者:笑看风声 时间:2022-08-07 01:52:16
我就废话不多说了,直接上代码吧!
#2.14
from turtle import *
from time import sleep
def go_to(x, y):
up()
goto(x, y)
down()
def head(x,y,r):
go_to(x,y)
speed(1)
circle(r)
leg(x,y)
def leg(x,y):
right(90)
forward(180)
right(30)
forward(100)
left(120)
go_to(x,y-180)
forward(100)
right(120)
forward(100)
left(120)
hand(x,y)
def hand(x,y):
go_to(x,y-60)
forward(100)
left(60)
forward(100)
go_to(x, y - 90)
right(60)
forward(100)
right(60)
forward(100)
left(60)
eye(x,y)
def eye(x,y):
go_to(x-50,y+130)
right(90)
forward(50)
go_to(x+40,y+130)
forward(50)
left(90)
def big_Circle(size):
speed(20)
for i in range(150):
forward(size)
right(0.3)
def line(size):
speed(1)
forward(51*size)
def small_Circle(size):
speed(10)
for i in range(210):
forward(size)
right(0.786)
def heart(x, y, size):
go_to(x, y)
left(150)
begin_fill()
line(size)
big_Circle(size)
small_Circle(size)
left(120)
small_Circle(size)
big_Circle(size)
line(size)
end_fill()
def main():
pensize(2)
color('red', 'pink')
head(-120, 100, 100)
heart(250, -80, 1)
go_to(200, -300)
write("To: 智慧与美貌并存的", move=True, align="left", font=("楷体", 20, "normal"))
done()
main()
运行结果:
来源:https://blog.csdn.net/weixin_37716512/article/details/87560276
标签:Python,发射,爱心
0
投稿
猜你喜欢
python 如何利用chinese_calendar 获取上一个工作日日期
2022-01-12 12:07:32
python构造IP报文实例
2023-07-10 20:40:51
python使用selenium打开chrome浏览器时带用户登录信息实现过程详解
2023-07-19 05:00:37
微信公众平台开发入门教程(图文详解)
2023-06-21 11:10:05
使用Python中的greenlet包实现并发编程的入门教程
2023-10-18 08:29:00
精细讲述SQL Server数据库备份多种方法
2009-01-13 13:33:00
Python用摘要算法生成token及检验token的示例代码
2022-05-30 10:22:10
ASP在服务器自动解压RAR文件
2010-04-24 16:06:00
Django-silk性能测试工具安装及使用解析
2023-12-08 08:53:19
Python提取特定时间段内数据的方法实例
2023-09-12 05:21:49
Tensorflow2.1实现Fashion图像分类示例详解
2021-01-28 03:59:52
python使用turtle库绘制树
2022-04-14 09:09:06
ExecuteReader(),ExecuteNonQuery(),ExecuteScalar(),ExecuteXmlReader()之间的区别
2023-07-08 23:15:54
Python 中Operator模块的使用
2021-04-02 05:30:34
show一下刚做的系统登录界面
2008-09-13 19:13:00
SQL Server 2000数据库FOR XML查询概述
2008-12-09 14:49:00
Javascript 中对中文长度对行判断
2009-07-05 18:39:00
Go 语言进阶freecache源码学习教程
2023-08-06 03:05:20
简化的CSS Reset — 常用CSS重设实例
2009-03-11 16:46:00
实例简析XPath串函数和XSLT
2008-09-04 14:16:00