[Basic Python] 01. Introduction to Python

1 Basic concepts of Python language

  • Python is an interpreted language.
  • Python is one of the very few programming languages ​​that is both simple and powerful. You will be surprised to find that the programming language you are using is so simple, it focuses on how to solve problems, not on syntax and structure.
  • The official introduction to Python is as follows:

    Python is an easy-to-learn and powerful programming language. It has a high-efficiency data structure and can implement object-oriented programming simply and effectively. Python's concise syntax and dynamic input characteristics, combined with its interpretive language nature, make it an ideal language for scripting and rapid application development in a variety of fields and most platforms

  • Guido van Rossum, the creator of Python. The reason why Python (the meaning of python) was chosen as the name of the programming language was taken from the British TV comedy "Monty Python's Flying Circus" premiered in the 1970s.

2 Features of Python

2.1 Advantages

1. Simplicity : Python is a language that represents simplicity. Reading a good Python program feels like reading English. It enables you to focus on solving problems rather than understanding the language itself.
2. Easy to learn : Python is extremely easy to use, because Python has extremely simple documentation.
3. Standardized code : Python uses forced indentation to make the code more readable. Programs written in Python do not need to be compiled into binary code.
4. Free and open source : Python is one of FLOSS (free / open source software). Users can freely distribute copies of this software, read its source code, make changes to it, and use part of it in new free software. FLOSS is based on the concept of a group sharing knowledge.
5. Portability : Due to its open source nature, Python has been ported on many platforms (after modification, it can work on different platforms). These platforms include Linux, Windows, FreeBSD, Macintosh, Solaris, OS / 2, Amiga, AROS, AS / 400, BeOS, OS / 390, z / OS, Palm OS, QNX, VMS, Psion, Acom RISC OS, VxWorks Android platform based on Linux developed by PlayStation, Sharp Zaurus, Windows CE, PocketPC, Symbian and Google.
6. Scalability : If you need a piece of critical code to run faster or you want certain algorithms not to be public, you can write part of the program in C or C ++, and then use them in the Python program.
7. Embeddability : Python can be embedded in C / C ++ programs to provide script functions to program users.
8. Rich library: The Python standard library is really huge. It can help with various tasks, including regular expressions, document generation, unit testing, threads, databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML, WAV files, password systems, GUI ( Graphical user interface), Tk, and other system-related operations. This is called Python's "full-featured" concept. In addition to the standard library, there are many other high-quality libraries, such as wxPython, Twisted, and Python image libraries.

2.2 Disadvantages

1. Slow running speed : This is compared with C and C ++. Because Python is an interpreted language, your code will be translated line by line into machine code that the CPU can understand when it is executed. This translation process is very time-consuming, so it is very slow. The C program is directly compiled into machine code that the CPU can execute before running, so it is very fast.
2. Difficulties in source code encryption : both advantages and disadvantages, Python's open source makes the Python language can not be encrypted. Unlike a compiled language, the source program will be compiled into the target program, so it is more difficult to encrypt the source code.
3. Too many framework choices : (There is no official .net framework like C #, nor is it like ruby. Due to the short history, the framework development is relatively concentrated. The Ruby on Rails framework develops small and medium-sized web programs that are invincible in the world). But this also shows from another side, python is better, attracts more talents, and has more projects.

3 Development and application of Python

3.1 Development of Python

If you have heard of the TIOBE leaderboard, you will know the general popularity of programming languages. This is the change chart of the 10 most commonly used programming languages ​​in the last 10 years:
The development of programming languages ​​in the last ten years
from the ranking list, we can find that Python has become a very popular language. Many large websites are developed using Python, such as YouTube, Instagram, and domestic Douban. Many large companies, including Google, Yahoo, and even NASA (NASA) use Python extensively.

3.2 Application of Python

1. Conventional software development
Python supports functional programming and OOP object-oriented programming, and can undertake any kind of software development work, so conventional software development, scripting, network programming, etc. are all standard capabilities.
2. Scientific computing
With the development of many libraries such as NumPy, SciPy, Matplotlib, Enthoughtlibrarys, etc., Python is more and more suitable for scientific computing and drawing high-quality 2D and 3D images. Compared with the most popular commercial soft Matlab in the field of scientific computing, Python is a general programming language, which is more widely used than the scripting language adopted by Matlab and has more program library support. Although many advanced functions and toolboxes in Matlab are still irreplaceable, there are still many tasks that can be done with Python in daily scientific research and development.
3. Automated operation and maintenance
This is almost a reserved place for Python applications. As the preferred programming language for operation and maintenance engineers, Python has been deeply rooted in automation and maintenance. For example, Saltstack and Ansible are well-known automation platforms.
4. Cloud computing The
open source cloud computing solution OpenStack is developed based on Python, and all students who engage in cloud computing understand it.
5.
WEB development Don't have too many web development frameworks based on Python, such as familiar Django, Tornado, Flask. Among them, the Python + Django architecture has a very wide range of applications, a very fast development speed, and a low learning threshold, which can help you quickly build an available WEB service.
6. Web crawler
Also known as web spiders, it is a core tool for data acquisition in the big data industry. Without a web crawler that crawls free data on the Internet automatically, day and night, and highly intelligently, companies that are related to big data may be three-quarters less. There are many programming languages ​​that can write web crawlers, but Python is definitely one of the mainstream, and its Scripy crawler framework is widely used.
7. Data analysis
On the basis of a large amount of data, combined with scientific computing, machine learning and other technologies, cleaning, deduplication, normalization and targeted analysis of data is the cornerstone of the big data industry. Python is one of the mainstream languages ​​for data analysis.
8. Artificial Intelligence
Python is a mainstream programming language in machine learning, neural networks, deep learning, etc. in the field of artificial intelligence, and has been widely supported and applied.

4 Zen of Python

Type import this in the python editor

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea – let’s do more of those!
译文:
Python之禅

Beautiful is better than ugly (Python aims to write beautiful code).
Clear is better than obscure (beautiful code should be clear, naming conventions, similar styles)
concise is better than complex (beautiful code should be concise, not complicated Internal implementation)
Complexity is better than clutter (if complexity is unavoidable, then there can be no incomprehensible relationship between codes, keep the interface simple)
Flat is better than nesting (beautiful code should be flat, there can not be too much nesting )
Interval is better than compact (beautiful code has proper interval, do n’t expect a line of code to solve the problem)
readability is very important (beautiful code is readable),
even if you borrow the name of the practicality of the special case, you cannot violate these rules These rules are paramount)
Don't tolerate all errors unless you are sure you need to do so (accurately catch exceptions and don't write except: pass style code)
When there are many possibilities, don't try to guess
but try to find one, it is best to the only obvious solution (if in doubt, use brute-force method)
, although this is not easy, because you are not Python Father (Dutch here refers Guido)
do not do better than might, but might as well do without thinking on the hands (hands prior to meditate)
If you can not describe your plan to people, it is certainly not a good program; and vice versa (Plan evaluation standard)
Namespace is a wonderful concept, we should make more use of it (advocacy and call)

Published 5 original articles · praised 3 · visits 319

Guess you like

Origin blog.csdn.net/qq_37572548/article/details/105332975
Recommended