Python from getting started to abandoning Qaq

Source: Internet
Author: User
Tags naming convention

First, the founder and history of Python

Guido van Rossum, 1989 Python was born.

1991, a Python compiler was born, he was implemented in C language, and be able to call the C language library file.

2008 Python launched version 2.6 and 3.0, since the 2.6 version has been violated by Uncle Turtle to create python, concise, graceful, clear, simple idea, turtle uncle introduced himself modified 2.6 and the new launch of 3.0, and said in 2020 no longer update the 2.0 version.

Ii. scope of application of Python

Python can be used in many fields, such as data analysis, building inheritance, Network Service, image processing, numerical computation and scientific neighborhood.

Third, what kind of language is Python?

1, programming language mainly from a few angles of classification, compilation and interpretation type, static language and dynamic language, strong type definition language and weak type definition language.

2. What is the difference between compilation and interpretation?

compiler is to all the source program each statement is compiled into binary, so that the machine can be run directly, the program runs fast.

The interpreter is executed at the time of the execution of the program in a code that is interpreted as a binary, so the running speed is slow and the running program is fast without compiling.

3, the compiler language has

C \ C + + \ GO \ Swift \ object-c \ Pascal

The explanatory language has

JavaScript \ Python \ Ruby \ PHP \ Perl \ Erlang

Mixed languages have

JAVA \ C #

Iv. advantages and disadvantages of compiling and interpreting types

Compiled type

Advantage: The compiler will have a precompiled process to optimize the code, because only compile once, the runtime does not need to compile, so the compiler is very efficient, can be run independently of the language environment.

Cons: After compilation, if need to re-modify the entire module to recompile, compile-time according to the corresponding environment to generate machine code, the migration between different operating systems is problematic, you need to compile different executables according to the running operating system environment. 4

Explanatory type

Pros: Good platform compatibility, can be run in any environment, provided the interpreter (virtual machine) is installed. Flexible, modify the code can be directly modified, can be quickly deployed, without downtime maintenance.

Cons: Each time you run the time to explain, performance is not as good as the compiled type.

V. Advantages and disadvantages of Python

Advantages

1, Python positioning, clear, elegant, simple.

2, the development of high efficiency, Python has a very powerful third-party library.

3, high-level language.

4, portability.

5, scalability.

6, can embed sex.

Disadvantages

1, the speed is slow.

2, the code can not be encrypted.

3, the thread can not take advantage of multi-CPU problems.

V. the Python Interpreter

CPython

Running Python at the command line is the start of the CPython interpreter.

CPython is the most widely used Python interpreter.

IPython

Ippython is an interactive interpreter based on CPython, Ipython is only enhanced in interactive mode, and the function of executing Python code is the same as CPython.

PyPy

PyPy its goal is to execute speed and to dynamically compile (not interpret) Python code, which can significantly improve the execution speed of Python code.

Jython
Jython is a Python interpreter on the Java platform. You can simply compile the Python code into Java bytecode to hold the line.

IronPython
IronPython and Jython are similar, but not only IronPython is the shipping line in Microsoft. NET platform, you can directly compile the Python code into. NET bytecode.

Vi. Variables and constants

1. Variables

Variable: The intermediate result of the operation is staged into memory for subsequent program tuning. A naming convention for variable quantities:
1, the variable volume by the word, the number, the underline with the combination?
2. Start with a number, not a full number.

3, can not be pythond keyword, these symbols and words? The parent has been used by Python, can not be changed

4, no? In the text

5, the name should have meaning

6, not too long.

7, distinguish between big and lowercase

What do you recommend? Use a camel or an underscore to name the hump: apart from the first word, every other word in the mother? Uppercase underline: Between each word? Underline apart

2. Constants

There is no absolute constant in Python, the Convention is commonly known, all letters capitalized even if the constant

Example: PI = 3.1415926

Birth_sylar = 1990

Vii. notes

Single-line Comment: #被注释内容

Multiline Comment: # "" "Annotated Content" "" "This is also a multiline comment"

VIII. basic data types for Python

1, Integer (int)

Common numbers are int, which is used for comparison of calculations or sizes.

The range of int on a 32-bit machine is -2**31~2**31-1, which is -2147483648~2147483647

The range of int on a 64-bit machine is: -2**63~2**63-1, which is -9223372036854775808~9223372036854775807

2. String (str)

In Python, all quotes are quoted as strings.

Strings can be used, single quotes, double quotes, three quotation marks, no difference, just some special formatting need not the quotation marks.

msg = "My name is Alex, I ' m years old!" This requires single double quotes.

msg = "" "

Today I want to write a poem,

Sing the praises of my deskmate,

You see his black short hair,

Like, a fried chicken.

"""

Want more? row and row assignments? A string of characters, you need three quotes.

Are there +-*/string strings for numeric types?

String strings are only + *.

#字符串串的拼接

S1 = ' a '

s2 = ' BC '

#print (S1 + s2)
#相乘 Str*int

Name = ' strong '

#print (NAME*8)

Ix. User interaction

Using the input () function allows us to interact with the computer.

Grammar:

Content = input (hint message)

Here you can get direct access to what the user has entered.

Process Control if statement

The first syntax:

If condition: #引号是将条件与结果分开.

Result 1. # four spaces, or? A TAB key, this is the condition that tells the program full?

Result 2. If the condition is true (true) the row row Results 1, then result 2, if the condition False (false) direct result 2

The second type of syntax:

If Condition:

Results 1

Else

Results 2

Code 3

The third type of syntax:

If Condition 1:

Results 1

Elif Condition 2:

Results 2

..

Else

Result N

Fourth syntax (nested):

If Condition 1:

Results 1

If Condition 2:

Results 2

Else

Results 3

Else

Results 4

Yes, unlimited nesting. But in the actual development. Try not to exceed three levels of nesting

Python from getting started to abandoning Qaq

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.