Python Basics (i)

Source: Internet
Author: User

 The history of programming languages and the development of Python one. programming language 1. Programming language is also "language" with English, Chinese and other similar, mastering its grammatical structure, flexible use of its grammatical rules is important. The           programming language implements the communication between the programmer and the computer to make the computer work.  2. Programming language Classification Machine language: Typical binary code represents a language that the computer can recognize. Advantages: Flexible, direct execution, and fast speed disadvantage: Different models of machine language is not the same, according to a machine instructions written by a program can not be executed on other models of the computer. Assembly language: Human-defined binary code in English instead, identifiers easier to identify and remember.  It also requires programmers to write each step of a specific action in the form of a command.  Advantages: The ability to complete a high-level language can not be completed, and the output of the production of the executable file is relatively small, and fast execution. Cons: Code is verbose, complex, error prone, and using assembly language requires more knowledge of computer operations. High-level language: In addition to using characters that are more recognizable.  High-level language is the choice of most programmers, want to compare the assembly language is more simple basically make up for the Short board assembly language, and the requirements of the programmer's knowledge without assembly language complex. Advantages: Greatly simplifies the instructions in the program.  Programmers do not need too much, too complex to concentrate on knowledge. Disadvantage: High-level language programming program can not be directly recognized by the computer, must be converted to and execute, so the execution speed will be slow.  They can be divided into two categories by conversion: interpreted: The code for a line of lines is interpreted by the interpreted type.  Advantages: Convenient and flexible, easy to debug the program, once the program error, you can directly debug the results can be tested. Cons: Inefficient, and unable to produce executable files that can be executed, because in the execution of the program needs to be interpreted by the interpreter as a machine language to let the computer execute, so its speed is not as fast as the compiled type.  Compiled: Compiles code into two-level code that can be recognized by the computer before it executes, and can be directly executed for compilation.  Advantages: The compiled code can be run directly on the machine and run at a higher speed than the interpreted type. Cons: Debug program Trouble, once the program needs to modify the source code, and then recompile to execute. The history of programming languages has gone through: Machine language----> assembly language-------> High-level language 1. Development efficiency from low to high 2. The efficiency of the implementation from high to low 3. Mastering difficulty from difficult to easy 3. The history of Python and its advantages and status during the Christmas of 1989 the Scripting interpreter developed by Guido van Rossum experienced the history of this many versions of the Python interpreter-1991, the first Python compiler was born. It isIt is implemented in C language and can call the C language library file. From birth, Python already has: classes, functions, exception handling, core data types including tables and dictionaries, and module-based expansion systems. -Granddaddy of Python Web frameworks, Zope 1 is released in 1999-python 1.0-january 1994 added  LAMBDA, MAP,&N bsp;filter and reduce.-python 2.0-october 16, 2000, added a memory recovery mechanism that forms the basis of the Python language framework now-Python 2.4-november 30, 20 04, the same year currently the most popular web framework Django was born-Python 2.5-september, 2006-python 2.6-october 1, 2008-python 2.7-july 3, 2010-in N Ovember, it is announced that Python 2.7 would is supported until 2020, and reaffirmed that there would is no 2.8 re Lease as users were expected to move to Python 3.4+ as soon as Possible-python 3.0-december 3, 2008-python 3.1-june 2009-python 3.2-february, 2011-python 3.3-september, 2012-python 3.4-march, 2014-python 3.5-septe Mber, 2015 python currently ranks fifth in a variety of programming languages. Each major mainstream web site has a python figure, known as the beautiful language.  Two. There are two ways to get started with Python 1.Python: 1. Interpreter: The terminal interaction can debug the code immediately, but the code cannot be persisted because the code is lost when it is written and the interpreter that writes the memory exits.  2. File form: Permanently save the code in the form of a file, ending with a. py file. Emphasis toFile form to record code file header/usr/bin/env Python-*-conding:utf-8-*-print (' Hello World ') 2.python internal code execution process  

Note: When the line comment # Plus the commented content multiline comment ' "' is annotated content ' '" ' pyc file executes Python code, if another. py file is imported, a. pyc file with the same name as the Python interpreter is automatically generated during execution.   The byte code generated after the translation.  PS: Code is compiled to generate bytecode, and bytecode can be obtained by decompile. 3. Variable name1= ' LHF ' name2= ' Egon '

This image can be used to illustrate how Python variables are defined: Each defining a variable creates a space in memory to store the value of the variable. Another: Name1=niubin name2=name1 if name1 is changed to Bin name2 or equals niubin This is the Python variable three. Python Syntax 1). Input output Python2 input is Raw_input Python3 The inputs are input output with print prints (' output value ') 2) operator 1. Arithmetic operator

2. Comparison operation:

3. Assignment operators:

The Process control syntax is similar to the shell but more flexible than the shell if you judge print (") Else print (') Single branch versus multi-branch single If else is a single branch multi-branch elif else while loop while bar Pieces: Loop body If the condition is true, then the loop body executes if the condition is false, then the loop body does not break to exit this layer loop continue for the next loop for the exit loop for loop for I in range (): Prin T (")

Python Basics (i)

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.