Operating system
1, what is the operating system
The operating system is located between the computer hardware and the application software
is a control program that coordinates, manages and controls computer hardware resources and software resources.
2. Why do I have an operating system?
1. Control hardware
2, the complex operation of the hardware package into a beautiful simple interface (file), to users or applications to use
Note: A complete set of computer systems consists of three parts
Application: QQ, Storm audio, fast broadcast
Operating system: Windows,linux,unix
Computer hardware
Emphasize:
We'll be developing applications later.
The application cannot manipulate the hardware directly, it is the interface that invokes the operating system whenever the hardware is to be operated
Programming language classification
1, machine language: Directly with the binary programming program, direct operation of the hardware
Advantages: High Execution efficiency
Cons: Low development efficiency
2, assembly language: The use of English tags to replace the binary instructions, the essence or directly operating hardware
Advantages: High efficiency compared to machine language development
Cons: Execution is low relative to machine language
3. Advanced language
The high-level language directly to the human can understand the language and grammar style to write programs, programmers no longer need to consider complex hardware operations
The problem is that the programs we write in high-level languages are ultimately going to be executed for the computer, which involves a translation process
To translate a program written in a high-level language into a binary instruction that can be understood by a computer, according to the different ways of translation,
High-level languages are divided into two major categories
Compiled type: C
Advantages:
Faster execution efficiency than explanatory type
Disadvantages:
Development efficiency is better than explanatory type
Interpreted type: python
Advantages:
The development efficiency is higher than the compiled type
Disadvantages:
Slower execution efficiency than compile-time
Implementation efficiency is also limited by the speed of the network, so we need to prioritize at this stage is the development of efficiency
Two ways to execute Python
1. There are two ways to execute a python program
I: Interactive
Pros: Debug Programs
Cons: Unable to permanently save code
II: The way of the command line
Python3 D:\p1.py
Pros: You can permanently save your code
2. Python executes three stages of the program: Python3 D:\p1.py
1. Start Python3 Interpreter First
2. The Python3 interpreter reads the file contents D:\p1.py from the hard disk into memory like a text editor
3. Python3 Interpreter explanation execution file code
Emphasis: Only the third stage recognizes the Python syntax
Variable
‘‘‘
1. 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
2, why should have the variable
The essence of program execution is a series of state changes
3. How to use variables
‘‘‘
#一: Defining variables
# name= ' Egon '
# age=18
# sex= ' Male '
# height=1.81
# weight=160
#总结: Define variables into three parts
#1, variable name: The variable name is used to reference the value of the variable. That is, whenever you want to use a variable value, you need to pass the variable name
#2, assignment symbols: assigning values
#3, variable value: That is, the data we hold is used to record a certain state in the real world.
# print (name)
# age=19
# height=1.82
#
# print (age)
# Print (height)
#二: Naming conventions for variable names
#大前提: The naming of variable names should reflect the status recorded by the value of the variable
#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 '
#三: Two flavors of variable names
#1, Hump body
# ageofoldboy=73
#2, underline (for the naming style of variable names, underline + plain lowercase letters are recommended)
# age_of_oldboy=84
#四: constants: Unchanging quantities
#强调: There is no mandatory definition of constants in Python from a syntactic point
#如果在python中需要定义常量, you should change the variable name all to uppercase
age_of_oldboy=84
# age_of_oldboy=85
# Print (Age_of_oldboy)
Python memory management
#coding: Utf-8
#引用计数增加
# x=10 #10身上的引用计数加1
# y=x #2
#引用计数减少
# x=11 #10身上的引用计数减少1
# del y #del的意思是解除绑定, 10 reference count reduced by 1
#引用计数一旦为0, is garbage, will be automatically recycled by the Python garbage collection mechanism
#python的内置功能id (), each variable value has its memory address, and the ID is used to reflect the value of the variable in memory location, the memory address different ID is different
# x= ' Info:<name:egon age:18 &/-=> '
# y= ' Info:<name:egon age:18 &/-=> '
# Print (ID (x))
# Print (ID (y))
# x=10
# y=10
#
# Print (ID (x))
# Print (ID (y))
# x= ' Egon '
# y= ' Alex '
# Print (ID (x))
# Print (ID (y))
Defining three characteristics of a variable
# x= ' Egon '
#
# #id
# Print (ID (x))
# #类型
# Print (type (x))
# #值
# Print (x)
#判断值是否相等: = =
# name1= ' Egon '
# name2= ' Egon '
# print (name1 = = name2)
#判断id是否相等: Is
x=11
Y=x
# print (x = = y)
Print (x is y)
#总结:
#1, ID equal, value must be equal
#2, values are equal, IDs are not necessarily the same
‘‘‘
>>> x= ' info<egon:18> '
>>> y= ' info<egon:18> '
>>>
>>>
>>>
>>> ID (x)
1484352906224
>>> ID (y)
1484352906416
>>>
>>> x is y
False
>>> x = = y
True
‘‘‘
Operating system, programming language classification, executing python Two ways, variables, memory management, defining three characteristics of a variable