Article From:

I. Types of programming languages:

     1.Machine Language: Direct use of binary instructions to write programs, direct operation of hardware (from the machine’s point of view)

     2.Assembly Language: To write programs in English instead of binary, or to operate hardware directly (from the machine’s point of view)

     3.High Level Language: Programming in human expression, indirectly operating hardware through the operating system (from the human point of view)

                       Compiler: A compiler is needed, similar to Google Translate, but its cross-platform performance is poor.

                                     The compiled program does not need to be re-translated when it runs. It just uses the compiled results directly.

                       Interpretative: need interpreter, similar to simultaneous interpretation, cross-platform good

                                     The source code of the application is interpreted by the interpreter and executed at the same time. It can not be separated from the interpreter.

     Executive efficiency: machine language & gt; assembly language & gt; compiler & gt; interpreter

     Development efficiency: interpretative & gt; compiler & gt; assembly language & gt; machine language

Conclusion:Speed is not the key, development efficiency is the king. Python is an interpretative high-level language with the highest development efficiency and low threshold.

2. Install Python interpreter

     Set environment variables:

         win7: Right-click computer – attribute – environment variable – system variable – path – add path (D: Python 27; C: a b c; D: a\ b c;)


                 1.vim /etc/profile

                 2.Input a\i\o

                 3.Move the cursor key, move to the last line, enter


                     export  PATH

                  4.Press ESC, enter: WQ

                  5.source /etc/profile

Three. Two ways to execute Python programs

      1.Interactive environment: Used to debug programs, can not be permanently saved.

      2.Write the program into a file, save it permanently, and execute it in the following way:python3 D:\

       Three phases of running Python program:

                 1.Start the Python interpreter first

                 2.pythonThe interpreter reads the contents of the file into memory as normal file contents (without the concept of grammar)

                 3.pythonThe interpreter interprets the code that has just been read into memory and begins to recognize Python syntax

Four. Variables

     1.What is a variable?

           Quantity: Recording a state of something in the real world

           Change: A certain state of things can change.

     2.Why use variables

           In order to enable computers to record certain states of things like human beings

      3.How to use variables (Principle: Define first, quote later)

         3.1.First define


            The three main components of defining variables are:

               3.1.1 Variable name: The only way to access a value

               3.1.2 =:Bind the memory address of the variable value to the variable name

               3.1.3 The value of a variable: The data we store is used to represent a state of something.

          3.2.Post reference


      4.Naming of variable names

         4.1 Prerequisite: Variable names should have descriptive effects on values

         4.2 Naming specification

               4.2.1. Variable names can only be any combination of letters, numbers, or underscores

               4.2.2. The first character of a variable name cannot be a number

               4.2.3. Keyword cannot be declared as variable names [‘and’,’as’,’assert’,’break’,’class’,’continue’,’def’,’del’,’elif’,’else’,’exce’.Pt’,’exec’,’final’,’for’,’from’,’global’,’if’,’import’,’in’,’is’,’lambda’,’no’.T’,’or’,’pass’,’print’,’raise’,’return’,’try’,’while’,’with’,’yield’]

          4.3 Naming style

               4.3.1. Hump body


               4.3.2. Underline


5. Interacting with Users

     1.Receive user input

            Machines are dead, and we must write programs for them to run, which requires that our programming language can have a mechanism to interact with users and receive user input data.

          # name=input(“Please enter your name:”)#name=”egon”

          # print (name)


                    Code comment can be divided into single line and multi-line comment, single line comment with #, multi-line comment with three pairs of double quotation marks “”””

                    Principles of Code Annotation:

                            #1. You don’t need to annotate all of them. You just need to annotate the parts you think are important or difficult to understand.
                            #2. Notes can be in Chinese or English, but not in Pinyin.

     2.Format output

            # name=input(“Please enter your name: ” name =”wangke”

            # age=input(“Please enter your age: ” age=”18″

            # print(“my name is %s my age is %s“,%(name,age))

            # my name is wangke my age is 18(Result)

         This function can be achieved by receiving strings or numbers through% s character, and another kind of character% D can only receive numbers.

Link of this Article: First acquaintance with Python

Leave a Reply

Your email address will not be published. Required fields are marked *