Python Learning Notes-(a) first knowledge of Python

Source: Internet
Author: User

1, Python's past life

To fully understand a person, the first full understanding of his past and present; We learn language is the same routine

1.1 History of Python

Python (United Kingdom pronunciation:/?pa?θ?n/American pronunciation:/?pa?θɑ?n/), is an object-oriented, interpreted computer programming language, invented by Guido van Rossum in 1989, the first public release was released in 1991.

1.2 Python's now

The TIOBE programming language Community leaderboard is an indicator of popular trends in programming languages, updated monthly, based on the number of experienced programmers, courses, and third-party vendors on the Internet. Rankings are calculated using well-known search engines (such as Google, MSN, Yahoo!, Wikipedia, YouTube, and Baidu). The following is the June 2016 latest programming language leaderboard TOP20 list: ()

Top 10 long-term chart of programming languages ():

Features of 2.python2.1 python design positioning

Python's design philosophy is "elegant", "clear", "simple". The Python developer's philosophy is "in one way, it's best to have only one way to do something." When designing the Python language, Python developers tend to reject the fancy syntax when faced with a variety of options, and choose a syntax that is unambiguous and has little or no ambiguity. These guidelines are called Python maxims. Run import this in the Python interpreter to get a complete list.

What fields can 2.2 python apply to?
    • Programming languages

Python language can be used as a batch language, write some simple tools, processing some data, as other software interface debugging. Python language can be used as a functional language for the development of artificial intelligence programs, with most of the functions of Lisp language. Python language can be used as a process language for our common application development, and can be used as VB and other languages. Python language can be used as object-oriented language, with most object-oriented language features, often as a prototype of large-scale application software development, and then rewritten in C + +, some directly with Python to develop.

    • Database

Python is also very good at databases, can connect to a variety of databases, data processing, from a business-type database to open source database support. For example: Oracle,ms SQL Server and so on. There are multiple interfaces that can be connected to a database, including at least ODBC. There are many companies that adopt a python+mysql architecture. Therefore, mastering Python allows you to make full use of the object-oriented features in database processing.

    • Windows programming

Python can be used not only on UNIX-type operating systems, but also in Windows systems. By adding the Pythonwin module, you can invoke and build various resources in COM form, including invoking the registry, ActiveX controls, and various kinds of COM, the most common example being the process of working with Office documents and automatically generating documents and diagrams.
With Python, you can also use the Py2exe module to generate EXE applications. There are many other routine maintenance and management tasks that can be handed to Python to reduce the amount of maintenance. With Python, you can also develop GUI programs like Vb,vc,delphi, but they can be executed on multiple platforms. This is not inferior to Java in many ways.

    • Multimedia

With PiL, Piddle, Reportlab and other modules, you can handle images, sounds, videos, animations, and more to add brilliance to your program. Dynamic chart generation, statistical analysis charts can be done through Python. In addition, there is OpenGL. With the Pyopengl module, you can write a three-dimensional scene very quickly.

    • Scientific calculations

Python can play a unique role in the field of scientific computing in general. There are a number of modules that can help you work efficiently in computing mega arrays, vector analysis, neural networks, and more. Especially in the field of education and scientific research, can play a unique advantage.

    • Network programming

Python can be very convenient to complete the work of network programming, provide a number of solutions and modules, can be very convenient to customize their own server software, whether C/s, or b/s mode, there is a good solution.

    • Graphical user interface

Python can be very easy to implement GUI programming, through the TKINTER,WXPYTHON,QT and so on, you can write a powerful cross-platform user interface program as needed.

    • Game programming

Python is an early tool in game programming. Played an important role in Star Wars. Industrial Light, an industrial abbesses metro that acts as a stunt and animation in the "Abyss", "Star Trek", "Indiana Jones" Super blockbuster, uses Python to make commercial animations. Currently, it's perfectly possible to write very good game programs through Python.

    • Enterprise and Government application

At present, Python has successfully implemented enterprise-class applications, and in the world, many companies have used Python for enterprise-class software development and application, such as: ERP and CRM applications. At the same time, through the Python technology, the successful implementation of many government applications

    • Other
advantages and disadvantages of 2.3 python 2.3.1 Advantages
    • Simple

Python is a language that represents the idea of simplicity. Reading a good Python program feels like reading English, even though the requirements of this English are very strict! This pseudo-code nature of Python is one of its greatest advantages. It allows you to focus on solving problems rather than figuring out the language itself.

    • Easy to learn

As you will see, Python is extremely easy to get started with. As mentioned earlier, Python has a very simple syntax.

    • Free, open source

Python is one of the floss (free/open source software). Simply put, you are free to publish a copy of the software, read its source code, make changes to it, and use it as part of the new free software. Floss is the concept of sharing knowledge based on a group. This is one of the reasons why Python is so good, and it is created and constantly improved by a group of people who want to see a better python.  

    • High-level language

When you write programs in the Python language, you do not have to consider the underlying details such as how to manage the memory used by your program.  

    • Portability

Because of its open source nature, Python has been ported to many platforms (it has been modified to work on different platforms). If you are careful to avoid using system-dependent features, all your Python programs can run without modification on any of the platforms listed below. 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, PlayStation, sharp Zaurus, Windows CE and even PocketPC, Symbian, and Google Linux-based Android platforms!

    • Explanatory nature

This requires some explanation. A program written in a compiled language, such as C or C + +, can be converted from a source file (that is, C or C + +) to a language used by your computer (binary code, 0 and 1). This process is done through the compiler and different tags and options. When you run your program, the connection/reprint software copies your program from the hard disk into memory and runs. Programs written in the Python language do not need to be compiled into binary code. You can run the program directly from the source code. Inside the computer, the Python interpreter translates the source code into an intermediate form called bytecode, and then translates it into the machine language used by the computer and runs it. In fact, because you no longer need to worry about how to compile the program, how to make sure that the connection is reprinted with the correct library, and so on, all this makes using Python easier. Since you only need to copy your Python program to another computer, it will work, which makes your Python program easier to migrate.

    • Object oriented

Python supports both process-oriented programming and object-oriented programming. In a "process-oriented" language, a program is built from a procedure or simply a function of reusable code. In "Object-oriented" languages, programs are built from objects that combine data and functionality. Python implements object-oriented programming in a very powerful and simple way, compared to other major languages such as C + + and Java.  

    • Scalability

If you need a piece of your critical code to run faster or you want some algorithms to be private, you can write some of your programs in C or C + + and then use them in your Python program.  

    • can be embedded

You can embed python in your C/C + + program to provide scripting functionality to your program users.  

    • A rich library

The Python standard library is really huge. It can help you with all kinds of work, including regular expressions, document generation, unit tests, threads, databases, Web browsers, CGI, FTP, e-mail, XML, XML-RPC, HTML, WAV files, cryptography systems, GUI (graphical user interface), TK, and other system-related operations. Remember that all of these features are available as long as Python is installed. This is called Python's "fully functional" concept. In addition to the standard library, there are many other high-quality libraries, such as Wxpython, twisted, and Python image libraries, and so on.  

    • Summarized

Python is really a very exciting and powerful language. It combines the high performance with the simple and interesting features that make the program easy to write.  

    • Code of the specification

Python uses forced indentation to make the code extremely readable.

2.3.2 Disadvantages
    • Force indent

This may not be referred to as limitation, but it is also confusing for many beginners by indenting the way in which the statements are differentiated. Even the most experienced Python programmers can get caught up in a trap. The most common scenario is that the mix of tabs and spaces can cause errors, which cannot be separated by the naked eye. But in fact, this refers to the slow running speed in most cases the user is not directly aware of, must rely on testing tools to reflect, such as you use C a program to spend 0.1s, Python is 0.01s, so C language directly than Python faster 10s, is very exaggerated, But you can not directly perceive by the naked eye, because a normal person can perceive the time minimum unit is 0.15-0.4s around, haha. In fact, in most cases python has been fully able to meet your requirements for the speed of the program, unless you want to write to the speed of the most demanding search engine, in this case, of course, it is recommended that you use C to achieve.

    • Code cannot be encrypted

Because Python is an explanatory language, its source code is stored in the form of a name (but I do not think this is a disadvantage, if your project requires that the source codes must be encrypted, you should not start with Python to implement)

    • Operating speed

Python runs much slower than the C language and is slower than Java.

    • Threads cannot take advantage of multi-CPU

This is the most common disadvantage of Python, Gil is the global interpreter lock (interpreter lock), is the computer programming language interpreter used to synchronize threading tools, so that at any moment only one thread in the execution, The python thread is the native thread of the operating system. On Linux for Pthread, on Windows for win thread, the execution of threads is fully dispatched by the operating system. A Python interpreter process has a main thread and the execution thread for multiple user programs. Multi-threaded parallel execution is prohibited even on multicore CPU platforms due to the existence of the Gil.

3.python Installation 3.1 Installation 3.1.1 Windows installation

First, depending on your version of Windows (64-bit or 32-bit), download the 64-bit installer or 32-bit installer for Python 3.5 from the official Python web site, and then run the downloaded EXE installation package to complete the installation.

PS: In particular, note the Add Python 3.5 to PATH, then click "Install Now" to complete the installation.

3.1.2 Mac Installation

If you are using a Mac and the system is OS X 10.8~10.10, then the Python version that comes with the system is 2.7. To install the latest Python 3.5, there are two methods:

Method One: Download the Python 3.5 installer from the Python website, double click to run and install;

Method Two: If homebrew is installed, install it directly from the command brew install Python3.

3.1.3 Linux Installation

Skip over 、、、

3.2 Run

After the installation is successful, there are two situations when you open a command prompt window and type python:

1):

See the above screen, it shows that Python installation success!

2) ' Python ' is not an internal or external command, nor is it a running program or batch file.

In this case, you need to configure the environment variable ...

Python Learning Notes-(a) first knowledge of Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.