Getting _Python shallow Day02 history programming language development

1. The history of the development of programming languages

  1.1 Machine Language

    Machine language that speaks a language understood by the machine (0100010101) binary representation.

    Machine language equivalent is to allow ourselves to learn the language of the machine, then it is saying to dialogue, to tell him what to do, but is binary machine language, language learning complex, development efficiency is too low.

  1.2. Assembly language

    Assembly language is used to represent a binary number by using some simple English sign, just coarse abuse simplifies the learning curve and optimizing the efficiency of development, relatively speaking, the development efficiency is still low

  1.3. High-level language

    High-level language is to allow our humanity to speak their own be able to read to understand it, and then through an interpreter, translating into a machine can understand it, control hardware instruction execution

    Divided into high-level language compiled and interpreted

    Compiled: Compiled compile once, run many times difficult to debug code, we need to re-debugging source code, compile, and debug source error again need to develop less efficient as c language...

    Interpreted: Compile a row, explaining his party, appeared bug can easily be debugged, high development efficiency as java, python and so on.

      

    Efficiency: the machine language assembly language >>> >>> high-level language

    The efficiency of development: high-level language >>> >>> machine language, assembly language

2.Python interpreter and runtime environment installed

  2.1.Python interpreter version

    Python2.7 version: Since version after Python3.0 did not do backward compatible, causing some continue to use 2.X version of the company do not want to use version 3.0, so the introduction of version 2.7, also the last 2 series version

    Python3.X Version: Most companies developed after the 3.0 version of the use 3.X versions, so learning to learn mainly based version 3.X, and recommended the market has passed the test of time over a longer version, such as 3.6 version

  2.2. Configuration Environment Variables

    You need to configure the environment variable After installing the 2.7 and 3.6 versions.

    Configuration (windows10): Desktop PC, click Right-click the attribute settings within >>> >>> Advanced System Environment Variables Advanced >>> >>> >>> New variable system variables corresponding write path Python interpreter environment variable .

3. First Python Program

  3.1 way Both run Python programs

    Interactive: typing can immediately return a corresponding result, the disadvantage is not permanently stored data

    Command line: you can permanently store data, run the file a little trouble

  3.2 To run a py file required:

    1. The Python interpreter loaded in memory

    2. py file is loaded into memory

    3.Python translation interpreter interpret py files become able to understand the instructions for the computer

  3.3. Variables

    Is used to represent a certain state or characteristics of things. Variables must be defined before calling, variable names can not be quoted

    Three elements of variables

      1.id (): Returns the string of numbers, it can be seen as a stored memory address.

      2.type (): returns the data type of the variable.

      () 3.value: is the value represented by the variable

    Variable naming

      1. hump notation (js recommended)

        SonOfBitch =('mm')

      2. underline notation (Python recommended)

         son_of_bitch =('mm')

  3.4. Small integer pool

    Python implementation int time there is a small integer pool. In order to avoid creating the same value is repeated application efficiency caused by the memory space, Python interpreter created when the starting pool small integer range [-5,256], small integer within the range of the object is global interpreter is reused within a range never be recovered GC

                >>> a = 257
                >>> b = 257  #定义两个相同的大于256的数字
                >>> id(a)
                2919979319120 #变量a的地址
                >>> id(b)
                2919979576208 #变量b的地址.ab超过了范围,地址不同
                >>> c = 256
                >>> d = 256  #定义两个相同的小于等于256的数字
                >>> id(c)
                1642892736
                >>> id(d)
                1642892736    #两个变量的地址相同,证明了小整数池            

 

  3.5.注释

    一个优秀的程序员都应该有良好的注释习惯,注释不只是给别人看的,也是给自己看的,当编写很多代码之后,可能你很早之前自己编写的代码都不太懂什么意思了,这是完全可能的,所以必须要有注释.

  3.6.垃圾回收机制

    1.引用计数:引用计数机制,看使用该数据的变量有多少个,根据多和少进行排列

    2.分代回收:根据数据使用的频率,时间分为不同的等级,等级低的优先回收

    3.标记清除:当内存将要被占满时,根据计数排列的多少,将计数为0的清除出内存

 

  3.7.常量

    Python中根本没有常量,常量是程序员们约定好的,变量名全为大写字母的作为常量使用,所以在Python中常量是可以修改的,但是最好不要修改.

    

Guess you like

Origin www.cnblogs.com/sxchen/p/11103942.html