A few small Python cases, fall in love with Python programming

Python is an object-oriented interpreted programming language. The source code and interpreter CPython comply with the GPL agreement, and the Python syntax is concise and clear.

The syntax is concise and clear, so what interesting things can we do with a small amount of Python code?

One, draw love confession

1. The graph is a curve composed of a series of points (X, Y). Since X and Y satisfy a certain relationship, we can build a model and establish an expression. When it is satisfied, two for loops (for X in range; for Y in range) will print each row and column.

2. Python code and comments:

Clarify the idea and realize one line of code:

It seems to be three lines, just write one line of Python code in the IDE, as shown in the figure:

This picture is a static picture, the effect is not satisfactory, so how about we make it a dynamic picture and realize the graphic confession? (You can change the content of the letters yourself)

The changed code is as follows:


For more cases, please click this, and show me you more knowledge

Guess you like

Origin blog.csdn.net/Python_xiaobang/article/details/112602424