day02-computer operating system and Python basic introduction

Source: Internet
Author: User

Introduction to computer operating systems and Python basics

1, what is the operating system?

The operating system is between the computer hardware and the application program

is to coordinate, control, manage the computer hardware resources and software Resources Control program

2. Why do I have an operating system?

1. Control hardware

2, the hardware complex operation package into a beautiful simple interface (file), for users or applications to use

3, a set of completed computer systems including Which?

Application

Operating system

Computer hardware

Note: We are developing applications in the future-applications cannot directly manipulate the hardware, and whenever you want to manipulate the hardware, it is the interface that invokes the operating system

4, machine language: directly with the binary operating hardware,

Advantages: Fast Running speed

Cons: Low development efficiency

Assembly language: Replace binary instructions with English tags, essentially in the direct operation of the hardware

Advantages: High efficiency compared to machine language development

Cons: Slow execution speed versus machine language

Advanced Language: Direct human understanding of language and grammar programming programs, programmers do not have to consider the computer complex hardware operation

Problem? The programs we write in high-level languages are ultimately going to be executed for the computer, which involves the process of translation

To translate a program written in a high-level language into a binary instruction that the computer can understand.

Classification of high-level languages:

Interpreted: Represents Python

Pros: Execution efficiency is slower than compile-time

Disadvantage: Development efficiency is faster than compile-type

Compiler type: C on behalf of

Advantages: Higher efficiency than explanatory type

Disadvantage: The development efficiency is lower than the explanatory type

But the efficiency of implementation is also limited to the speed of the network, so we need to consider the development efficiency

5. Two ways to execute a python program:

Interactive:

Pros: Quick Commissioning Program

Cons: cannot be saved permanently

Command-line mode:

Pros: You can permanently save your code

6. Python executes three stages of the program: Python3 D:\p1.py If there are spaces in the path, Python "D:\ee\e \p1.py"

1. Start the Python interpreter first

2. The Python interpreter reads the file contents from the hard disk into memory just like a text compiler

3. The Python interpreter interprets the execution file code (only the third stage recognizes the Python syntax)

7. What is a variable?

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

Change: The state of the real world is changing

8, why should have the variable

The essence of program execution is a series of state changes

9. How to use variables

One: Define Variables

Name= ' Egon '

sex= ' Male '

height=1.81

weight=160

Summary: Define variables into three parts

1. Variable name: The variable name is used to refer to the value of the variable. That is, whenever you want to call a variable value, you need to pass the variable name

2. Assignment symbol: Assign value

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

Two: Naming conventions for variable names

The premise: the name of the variable name should reflect the status of the variable value recorded

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

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

3. Keyword cannot be declared as a variable name

Username= ' Egon '

Print (username)

User_name= ' Egon '

Three: The two styles of variable names

1. Hump BODY

ageofoldboy=73

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

age_of_oldboy=84

Four: constants: Constant quantity

Emphasis: There is no syntactic imperative to define constants in Python

If you need to define constants in Python, you should change the variable names all to uppercase

age_of_oldboy=84

Reference count increased

x=10 10 on the body of the reference count plus 1

Y=x 2

Reference count Reduction

X=11 10 Reduced reference count by 1

Del y del means unbind, 10 reduced reference count by 1

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

Python's built-in function 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

Determine if the values are equal: = =

Determine if ID is equal: is

Print (x = = y)

Print (x is y)

Summarize:

1, the ID is equal, the value must be equal

2, the value is equal, the ID is not necessarily the same

day02-computer operating system and Python basic introduction

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.