Operating system + programming language category + variable day02

Source: Internet
Author: User

One, operating system 1, what is the operating system

The operating system is a control program that coordinates, manages and controls computer hardware resources and software resources between computer hardware and application software.

2, why should have the operating system

The computer itself is a very complex thing, which contains a lot of parts, CPU, memory, disk and so on, each of which contains a lot of small parts, if there is no operating system need to program all parts of the computer to study clearly, such as I/O port high and low levels, interrupts, registers and so can be used, It takes a lot of time and effort to study computer hardware, which seriously affects the development of software. So the operating system emerged.

There are two main functions, one of which is to control the hardware and encapsulate the complex operation into a graceful and simple interface for the user or application to use. The second is to realize the hardware sharing, the software realizes the orderly call to the hardware. If a few programs want to use a hardware resource at the same time, if no operating system is called directly, it will create confusion, the operating system can turn these unordered order.

  Emphasize:

The programs we develop later are applications where applications are not able to manipulate hardware directly, and any hardware that is to be manipulated is an interface that invokes the operating system.

II. Classification of programming languages 1. Machine language

  Write programs directly with binary programming

Advantages: High Program execution efficiency

Disadvantages: Learning difficulty, low development efficiency

2. Assembly language

Replace binary instructions with English tags, essentially or directly manipulate the hardware

Advantages: High efficiency relative to machine language development

Disadvantage: The execution efficiency is lower than the machine language, the learning difficulty is great

3. Advanced language

Direct human understanding of the language and grammar style to write programs, programmers do not have to consider complex hardware operations. A program written in a high-level language is still going to be performed on the computer, which involves a process of translation. High-level language → binary instructions, according to the different translation methods can be divided into the following two categories:

Compiled type:

On behalf of C language, the advantages: the execution efficiency is faster than the explanatory type, disadvantage: the development efficiency is lower than the explanatory type, debugging trouble, the cross-platform poor

Explanatory type:

For Python, advantages: the development efficiency is higher than the compiler type, convenient debugging, high cross-platform; Disadvantage: The execution efficiency is lower than the compiled type

  Note:

The efficiency of implementation is also limited by the speed of the network, so we have to prioritize the development efficiency at this stage.

More than three languages:

Learning difficulty from high to low

Execution efficiency from high to low

Development efficiency from low to high

A, two ways to execute a python program:

A, interactive:

Pros: Debug Programs

Cons: Unable to permanently save code

B, command line:

Python3 D:\p1.py

You can permanently save the code

B, Python Three stages of executing the program: Python3 D:\p1.py

A, start Python3 interpreter first

b, the Python3 interpreter, like a text editor, reads the file contents D:\p1.py from the hard disk into the memory strip

C, Python3 interpreter explanation execution file code

Note: The python syntax is recognized only in the third phase of Python3.

Third, variable 1. Whatis a variable

Change: The state of the real world changes

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

2, why should have the variable

The essence of program execution is a series of state changes,

3. How to define variables

  Define the variables into three parts

Variable name: Used to reference the value of the variable, that is, the value of the variable should be used, all need to pass the variable name

An assignment symbol (an equal sign): Assign a value

Variable value: That is, the data we store is used to record a certain state in the real world.

4. Naming conventions for variable names

A, the name of the variable names should reflect the status of the variables recorded

b, combined by letters, numbers, underscores, and the first cannot be a number

C, cannot use the keyword

5. Two styles of variable name

A, hump body

ageofoldboy=73

B, underline (for the name of the variable name style, the recommended use of underscores + plain lowercase letters)

age_of_oldboy=74

6. Constants

Constant amount of

 It is important to note that there is no mandatory definition of constants in Python, and if you need to define constants in Python, you should change the variable names to uppercase (conventional).

7. Python Memory Management

eg

x=10 #10身上引用计数加一

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

X=11 #10身上引用计数减一

Del y #del是解除绑定, 10 body reference count minus one

Note: Once the reference count is 0, garbage is automatically reclaimed by the Python garbage collection mechanism.

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

8. Defining the three characteristics of a variable

Id

Print (ID ())

Type

Print (type ())

Value

Print (x)

 Determine if the value is equal "= ="

Note: An equal sign is an assignment symbol, and the two equals sign determines whether the value is equal

Determine if ID is equal "is"

eg

x=11

Y=x

Print (x is y)

Run result True

Summary: A) id equal, value must be equal

b) The values are equal and the IDs are not necessarily equal

 

Operating system + programming language category + variable day02

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.