day2-operating systems, programming language classifications, two ways to execute Python programs, variables, Python memory management,

Source: Internet
Author: User
Tags naming convention

1 What is an operating system

Operating system is located between the computer and application software, is a coordination, management, control of computer hardware resources and software resources of the program

2 Why do I have an operating system?

1. Control the hardware. 2, the complex operation of the hardware package into a beautiful simple interface, to users or applications to use

a complete set of computer systems consists of three parts.

Applications: such as QQ, Storm video

Operating systems, such as Windows Linux Unix

Computer hardware

We are developing applications that do not directly manipulate the hardware, but are the interfaces that invoke the operating system, whenever you want to manipulate the hardware .

3 Classification of programming languages

1, machine language; directly using binary programming program, direct operation of hardware

The advantages of high execution efficiency

Disadvantages; Low development efficiency

2, assembly language; Replace binary instruction with English tag, essentially or in live operation hardware

The advantages are higher than the development efficiency of machine language.

A low performance relative to the machine language

3, high-level language

High-level languages directly use the language and grammar style that people can understand to write programs, and programmers no longer have to think about complex hardware operations. The problem is that we write in high-level language programs in the final analysis or to the computer to carry out, this involves a translation process, to be written in high-level language programs to the computer can understand the binary instructions to be executed, according to the different high-level language translation is divided into two major categories

Compile-type C, one-time translation. Advantages, the execution efficiency is faster than the explanatory type. Disadvantage, the development efficiency is inferior to the explanation type

interpreted Python; read while translating. Advantages, the development efficiency is faster than the compiled type. Disadvantage, the execution efficiency is slower than the compiled type

Implementation efficiency is also limited by the speed, so we need to consider at this stage is the development efficiency

4 Two ways to execute a python program

1, interactive, Advantage, debug program. Disadvantage, cannot be saved permanently

2, command line way, advantages, permanent Save code

Three stages of the Python execution program

1, start the Python interpreter first. The 2,python interpreter reads the contents of the file from the hard disk into memory just like a text editor. The 3,python interpreter interprets the execution file code. There is only a third stage to recognize the syntax of Python

5 variables

1, what is a variable

Measure/Record the state of the real world, so that the computer can be like people to identify the world of things

The state of the real world will change.

2, why do you have variables

The essence of program execution is a series of state changes

3, how to use variables

Like Name=aleax.

The definition variable is divided into three parts ; 1, the variable name is name, and the variable name is used to refer to the variable value. Whenever you want to use a variable value, you need to pass the variable name. 2, assignment symbol =; Assign value. 3, variable value aleax; The data we store is used to record a certain state of the real world.

A naming convention for variable names; The premise is that the naming of variable names should be able to reflect the state recorded by the value of the variable.

1, the variable name can only be a letter, a number or any combination of underscores such as; Name=aleax,na_me=aleax

2, the first character of a variable name cannot be a number

3,python keyword cannot be declared as a variable name

Two styles of variable names

1, Hump body Name=aleax

2, underline (for the name of the variable name style, the recommended use of underscores + plain lowercase letters) age_of_oldboy=84

A constant quantity; It is imperative to define constants in Python without grammatical meanings. If you need to define constants in Python, you should change the constant name all to uppercase. age_of_oldboy=84

Reference count increased

Like x=10 #10身上的引用计数加1

Y=x #10身上的引用计数加2

Reference count Reduction

Like x=11 #10身上的引用计数减少1

Del y #del的意思是解除绑定, 1 less reference count on 10

Reference count once 0,10 is garbage, it is automatically recycled by the Python garbage collection mechanism

Python's built-in feature ID (), each variable value has its memory address, and ID is used to reflect the value of the variable in memory location, memory address different ID is different

defines the three characteristics of a variable x=10;id (determines whether the ID is equal with IS), type (view type with print (type (x)), value (determines whether the value equals = =)

IDs are equal, values must be equal, values are equal, but IDs are not necessarily equal

day2-operating systems, programming language classifications, two ways to execute Python programs, variables, Python memory management,

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.