##### : Sun snow
Source: Python Technology [public ID: pythonall]

The Python technology is now more than a year old, and new knowledge, techniques, and tricks are constantly coming out, but one question many kids have: What is the use of all this programming knowledge, techniques, and tricks? Yes, technology is changing with each passing day, emerging in an endless stream, solutions are springing up like mushrooms, for us ordinary people, what is the use of programming, today I will talk about this problem, hope to inspire you.

Let’s start with three stories

So this is how you play 1

Before monthly salary is paid to employees, the salary sheet should be calculated, which requires personal social security deduction amount and attendance amount. Then, the financial department will deduct the deduction part from everyone’s basic salary and finally form the actual salary of employees.

It seems simple, but in fact it is troublesome to handle manually. The small screen is crowded with opened Excel, and the format and order of information in different reports are not consistent. In addition, staff changes and attendance have made it an arduous task, so the accountant has to work overtime before the monthly accounting

Last month, the accountant of the department asked for leave and could not deal with the salary calculation in time, so I was entrusted to help deal with it. We communicated with each other several times and repeatedly told each other that I might be worried about my slowness and delay the progress.

I didn’t plan to do it manually, but programmatically, so I wrote a Python script in my off-hours (extra work, after all) and finished it ahead of time. It went something like this:

  • Analyzed these reports and found the direct correlation of data (for example, employee name + employee number can be used as the basis for the direct data association of different reports)
  • Collate accounting fields (accounting items, such as medical insurance, provident fund, etc.)
  • Design processing rules (for example, which report to start with, and in what order to process the report)
  • Implement processing in Python, where Excel processing uses OpenPyXl (See Excel Artifacts — OpenPyXl)

When the accountant came back, he was amazed at how much effort he had saved. He asked, “How can I learn Python?”

Learning Python at age 25

In May this year (2020), Pan Shiyi, a real estate tycoon, passed the Python programming ability Level test with a score of 99:

As for why he learned to program, he wrote on his Micro blog:

In an agricultural society, we learn to drive horses, donkeys and cows, and make them work for us.

In industrial society, we have to learn to control all kinds of machines, trains, ships, planes, machine tools and so on.

Today, when we want machines to do what we want them to do, we need to learn languages that machines can understand.

In order to learn Python, Pan shiyi kept practicing and Posting his thoughts on his Micro blog. Many of his friends mistakenly thought that his micro blog account had been stolen

In an interview, he said that in the era of artificial intelligence, you need to learn the tools to work with machines, and the best tool is the Python programming language

Programming changes the way you think

When li Xiaolai, a big man in the currency circle, wrote a book, he wanted to explain that even if the conclusion is correct, the argument process is chaotic! This view requires an illustration.

At one point I found this saying:

If a equals 1, B equals 2, and C equals 3… Z is 26, then:

  • knowledge = 96
  • hardwork = 98
  • attitude = 100

So the conclusion is:

  • Knowledge and hardwork are both important;
  • But it is attitude that makes the difference!

The conclusion is correct, but the proof is so farfetched that how do you prove that the proof is ridiculous?

As long as you can find a word that has a negative meaning and a score of 100 according to the rules

But there are hundreds of thousands of English words, intuitively a manual calculation, will be exhausted, so in the face of such absurd proof process, but “speechless”

Fortunately, Li Xiaolai can program, through programming, quickly found more than three thousand “full marks” words, including:

  • Connivance
  • Coyness: That’s coyness.
  • Flurry
  • Impotence
  • Stress
  • Tuppence (trivial things)

Seeing this result, the absurdity of the process of deriving the conclusion becomes obvious

If you were to implement it, how would you do it? Get the keyword after the reply, you can get the reference code


In order to P y t h o n The language learning process as an example, expounds the process of self-study, which Take the learning process of Python language as an example to illustrate the process of self-study, wherein

In another book by Li Xiaolai, Self-Study is a Craft, there are many charts illustrating points of view. It is commendable that the charts are not graphic references, but are presented in Python code using raw data, such as the data illustration on life expectancy in China:

When we see a chart, we just glance at it and don’t think much about whether the data is right or whether the phenomenon is reasonable. With the help of programming tools, we can make a better and more reliable judgment on the conclusion or phenomenon

Self-learning is a Craft. This book describes the process of self-learning in Python. It is recommended as a tutorial for Python learning

What exactly is a program

The three stories illustrate the importance of programming from different angles, but in terms of practice, may not know how to apply, or solve practical problems

One important reason is that it does not establish a connection between its real world and the program world

In the program world, there are numbers, or information made up of numbers, while in the real world, there are concrete objects, or objects of abstract concepts, and there is no necessary correlation between numbers and objects.

Program structure

Modern computers are based on the Turing machine model

It mainly consists of three parts:

  • The input
  • To deal with
  • The output

For a computer, input is data, which is computed by the processor, and finally output the processed data

And the program is to instruct the computer how to process the data, can think of it as a processing unit, so each unit should also have its own input, processing and output

The input

The same is true for an application that solves a real problem, so the connection between the application and the real world is how do you digitize the real problem

This is where the challenge comes in. Some things are easy to quantify, like students’ test scores, and some things are hard to quantify, like people’s personalities

In addition to the challenge of digitization, there is also the problem of data volume

In the previous example of Li Xiao looking for “full score” words, the numbers are easy, the letters have a numerical code, but how to find all the words is a data volume problem

For the problem of data volume, the solution is to look for data sources. For example, Li Xiaolai found files containing all English words through search engines. Common methods are as follows:

  • Search for existing data sources
  • Crawl and collect scattered data across the network
  • Human input
  • Read through the API
  • .

To deal with

Once the data source problem is solved, we need to process the data, and the processing process is the part we are most familiar with and most practiced

Programming language tutorials are mostly about processing, and the exercises we encounter in learning programming often remove input problems, which helps us focus on processing itself

Nonetheless, the processing is always about dealing with data, dealing with data from a variety of sources:

  • From the file system
  • From the network
  • From interface variables, parameters
  • From the database
  • Output from other programs
  • Input from terminal

For each source, we learned how to parse, how to read, how to traverse, how to organize and store, etc. For example, the Open global method in Python can read a text file, the various data types in Python are used to store different forms of data, etc

When the data is received and analyzed, we can do processing, then we learned the program flow control, as well as a variety of computing methods.

Because information has been converted into data, or numbers, it can be used to perform operations, which is why mathematical knowledge is so important to computers, we need to translate practical problems (business problems) into a form that can be calculated using algorithms or mathematical formulas

For example, determining the relationship between multiple elements can be translated into figuring out the Euler distance between points in a multidimensional space. See “Python tells You How Scary it is to Spread an epidemic”, where the method used to determine whether an infection condition has been reached is to calculate the Euler distance between simulated points on a two-dimensional plane.

The output

After processing the data, you need to give a result, otherwise the program will be like a black hole, not knowing what it is

Corresponding to the input source, the output can be:

  • File system files
  • Network data
  • Method return value
  • The database
  • Terminal output

The output can be either storing the processed results for later use, or it can have an effect

The most direct effect is displayed on the screen, can be seen by people, through the light energy to transmit the results to people’s eyes, so as to have an impact

It can be imagined that if the medium of information transmission changes, the effect will be greatly different. For example, mechanical control software can control the machine with the results. The longest is the printer, we print the results on paper by driving the print needle and motor with electric energy

To put it bluntly, input and output is the interface or boundary between the program world and the real world. The existence of input and output combines the real world with the program world, so that the program has the ability to drive the world.

conclusion

This paper illustrates the importance of programming to us from several examples, and briefly explains the three components of a program from the perspective of program structure: input, processing and output, outline the basic outline of a program, so as to help understand the program.

From the first computer was born, the Internet information age now, decades, program changed human history, giving everyone the ability to change the world, now every aspect of our life is inseparable from the application of participation, and the participation will be more thorough, the speed will be faster, programming, for human and machine directly interact method more and more important, Just as Pan Shiyi said: We want to make the machine follow our command, we have to learn the language that the machine can understand.

reference

  • Github.com/selfteachin…
  • Finance.jrj.com.cn/tech/2019/1…
  • Baike.baidu.com/item/%E5%9B…

Welcome to follow the wechat official account: Python technology, here we have personally written 100 days of actual practice, there are all kinds of interesting programming practice, there are all kinds of learning materials, and a large group of lovely friends to discuss with each other.