Article \ | tide

Source: Python technology “ID: PYTHonAll”

Yesterday was 520, couples across the profession, the proposal of marriage, the license to license, here small make up also wish all shall be well, jack shall have Jill, if people do before because too busy yesterday or last night to find the goddess of the profession, the profession today please take small skills, believe are helpful to us as programmers, more creative!

Simple letter representation

import matplotlib.pyplot as plt
import seaborn
importNumpy # def < draw_love():0.4.0.01)
    L = 1.0 / l
    theta = numpy.arange(4 -.4.0.01)
    o = 3.0 * numpy.cos(theta)
    O = 3.0 * numpy.sin(theta)
    v = numpy.arange(4 -.4.0.01)
    V = numpy.abs(2.0 * v)
    e = numpy.arange(- 3.3.0.01)
    E = 1.0 * numpy.abs(numpy.sin(e))
    y = numpy.arange(- 10.10.0.01)
    Y = numpy.log2(numpy.abs(y))
    u = numpy.arange(4 -.4.0.01)
    U = 2.0 * u ** 2
    points = []

    for heartY in numpy.linspace(- 100..100.500) :for heartX in numpy.linspace(- 100..100.500) :if ((heartX * 0.03) * *2 + (heartY * 0.03) * *2 - 1) * *3 - (heartX * 0.03) * *2 * (
                    heartY * 0.03) * *3< =0:
                points.append({"x": heartX, "y"Heart_x = list(heartY})map(lambda point: point["x"], points))
    heart_y = list(map(lambda point: point["y"], points))13.7))
    ax_L = fig.add_subplot(2.4.1)
    ax_O = fig.add_subplot(2.4.2)
    ax_V = fig.add_subplot(2.4.3)
    ax_E = fig.add_subplot(2.4.4)
    ax_Y = fig.add_subplot(2.4.5)
    ax_O_2 = fig.add_subplot(2.4.6)
    ax_U = fig.add_subplot(2.4.7)
    ax_heart = fig.add_subplot(2.4.8Ax_L) # set coordinates. The plot (l, l) ax_O. The plot (o, o) ax_V. The plot (v, v) ax_E. The plot (E, E) ax_Y. The plot (y, y) ax_Y. Axis ([10.0.10.0.10.0.5.0])
    ax_O_2.plot(o, O)

    ax_U.plot(u, U)

    ax_heart.scatter(heart_x, heart_y, s=10, alpha=0.5Plt.plot (color='red'Plt.show (if __name__ == '__main__':
    seaborn.set_style('dark')
    draw_love()
Copy the code

The results are as follows:

GIF of a small heart

Small love confession detailed code as follows:

import turtle
import time

def hart_arc():
    for i in range(200):
        turtle.right(1)
        turtle.forward(2) def move_pen_position(x, y): turtle.hideturtle() # hide the brush (first) turtle.up() # take the pen turtle.goto(x, y) # Move the brush to the specified starting coordinate (window center is0.0) turtle.down() # display paintbrush love = input() # display paintbrush love = input()"Please enter the expression:")
signature = input("Please sign your name :")
date=input("Please write the date:")

if love == ' ':
    love = 'I Love You'

turtle.setup(width=800, height=500) # Window (canvas) size turtle.color('red'.'pink') # Brush color turtle.pensize(3) # Brush thickness turtle.speed(1Move_pen_position (x= 00, y=- 180.# Move the brush position turtle.left(140) # Turn left140Degree turtle.begin_fill() # Mark background fill position # Draw and show turtle.forward()224) # Move the brush forward with a length of224# hart_arc() # Turtle.left ()120# Right arc # Heart line (bottom right)224) turtle.end_fill() # Tag background fill end position move_pen_position(x=70, y=160# Move the brush position turtle.left(185) # Turn left180Degree of turtle. Circle (- 110..185) # Right arc # Heart line (bottom right) #turtle.left(bottom right)20) # Turn left180Degree of turtle. Forward (50)
move_pen_position(x=- 180., y=- 180.# Move the brush position turtle.left(180) # Turn left140Degree # Draw a heart-shaped line (lower left)600) # Move the brush forward with a length of224# move_pen_position move_pen_position0.50# hidden paintbrush turtle.color() # hidden paintbrush turtle.color()'#CD5C5C'.'pink'> > < p style = "text-align: center;'Arial'.20.'bold'), align="center") # Sign and dateif(signature ! =' ') & (date ! =' '):
    turtle.color('red'.'pink')
    time.sleep(2)
    move_pen_position(220.- 180.) turtle.hideturtle() # hide the paintbrush turtle.write(signature, font=('Arial'.20), align="center")
    move_pen_position(220.- 220.) turtle.hideturtle() # hide the brush turtle.write(date, font=('Arial'.20), align="center"Window = turtle.screen () window.exitonclick()Copy the code

The running effect is as follows:

The above small love is a GIF oh!

conclusion

This is the end of today’s small skills, everyone quickly take to use it, wish all lovers will be well, Jack shall have Jill!

PS: Reply “Python” within the public number, you can enter the Python novice learning exchange group, together with 100 days plan!

Old rules, brothers still remember, the lower right corner of the “see” point, if you feel the content of the article is good, remember to share circle of friends to let more people know!

【 Code access method ****】

Identify the qr code at the end of the text, reply: 20210521