python情人节之玫瑰花与表白方式_情人节 我用Python表白

情人节已到 我用Python来表白

情人节又叫圣瓦伦丁节或圣华伦泰节,即每年的2月14日,是西方国家的传统节日之一,起源于基督教。这是一个关于爱、浪漫以及花、巧克力、贺卡的节日,男女在这一天互送礼物用以表达爱意或友好。各位男同胞们、女同胞们该是给暗恋已久的恋人表白之日。今日你会运气爆棚,你所收获的结果都令你比较满意,对待感情会更加上心,职场魅力得到提升,人际关系融洽哦,财运表现不错呦。

福利时刻

(1)静态心

import matplotlib.pyplot as plt

import numpy as np

t=np.arange(0,2*np.pi,0.1)

x=16*np.sin(t)**3

y=13*np.cos(t)-5*np.cos(2*t)-2*np.cos(3*t)-np.cos(4*t)

plt.plot(x,y,color="red")

plt.show()

运行结果为:

b582c9f17d22927a311773ea00d836a5.png

(2)动态心

import turtle

from turtle import *

def curvemove():

for i in range(200):

right(1)

forward(1)

turtle.title("请人节")#为图像设置标题

turtle.pensize(width=5)#画笔宽度

color("red","pink")#画笔颜色以及填充颜色

begin_fill()

left(140)#逆时针旋转140度

turtle.speed(1)#画线速度

forward(111.65)#向前行走111.65

curvemove()#调用curvemove函数

left(120)

curvemove()

turtle.speed(1)

forward(111.65)

end_fill()

turtle.up()#停止画线

left(230)

forward(75)

turtle.write("I LOVE YOU ",align="Center",font=("Arial", 16, "normal"))

done()

运行结果如下:

18dcd6378300ec19833b5e5c184329b0.png

(3)一行代码画心

print('\n'.join([''.join([('AndyLove'[(x-y)%8]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-30,30)])for y in range(15,-15,-1)]))

运行结果为:

5f21fd0badc1de641cd154fa43fade5c.png

(4)玫瑰花

情人节,必不可少的是玫瑰花,那就用Python画个玫瑰花吧。

①定义画布和画笔

import turtle

def initialization():

turtle.setup(width=0.9, height=0.9)

turtle.speed(10)

②首先勾画花蕊

def flower():

turtle.goto(0, 200)

turtle.fillcolor("red")

turtle.begin_fill()

turtle.circle(10, 180)

turtle.circle(25, 110)

turtle.left(50)

turtle.circle(60, 45)

turtle.circle(20, 170)

turtle.right(24)

turtle.fd(30)

turtle.left(10)

turtle.circle(30, 110)

turtle.fd(20)

turtle.left(40)

turtle.circle(90, 70)

turtle.circle(30, 150)

turtle.right(30)

turtle.fd(15)

turtle.circle(80, 90)

turtle.left(15)

turtle.fd(45)

turtle.right(165)

turtle.fd(20)

turtle.left(155)

turtle.circle(150, 80)

turtle.left(50)

turtle.circle(150, 90)

turtle.end_fill()

③勾画左边的花瓣

def peta1():

turtle.left(150)

turtle.circle(-90, 70)

turtle.left(20)

turtle.circle(75, 105)

turtle.setheading(60)

turtle.circle(80, 98)

turtle.circle(-90, 40)

④勾画右边的花瓣

def peta2():

turtle.left(180)

turtle.circle(90, 40)

turtle.circle(-80, 98)

turtle.setheading(-83)

⑤勾画枝子上左边的叶子

def leaf1():

turtle.fd(30)

turtle.left(90)

turtle.fd(25)

turtle.left(45)

turtle.fillcolor("green")

turtle.begin_fill()

turtle.circle(-80, 90)

turtle.right(90)

turtle.circle(-80, 90)

turtle.end_fill()

turtle.right(135)

turtle.fd(60)

turtle.left(180)

turtle.fd(85)

turtle.left(90)

turtle.fd(80)

⑥勾画树枝上右边的叶子

def leaf2():

turtle.right(90)

turtle.right(45)

turtle.fillcolor("green")

turtle.begin_fill()

turtle.circle(80, 90)

turtle.left(90)

turtle.circle(80, 90)

turtle.end_fill()

turtle.left(135)

turtle.fd(60)

turtle.left(180)

turtle.fd(60)

turtle.right(90)

turtle.circle(200, 60)

if __name__ == '__main__':

initialization()

flower()

peta1()

peta2()

leaf1()

leaf2()

运行结果为:

f6314769bdf61633787d94d319a85637.png

写在最后:

已经结婚了的,有伴侣称为男女朋友的,该过得节日要过,该买的礼物要买,生活要有仪式感。没男、女朋友的,单身的狗狗们捉紧时间啦,表白给对的人。

最后的最后;

祝大家情人节快乐。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值