Python Introductory Learning-day02

Source: Internet
Author: User

Introduction of programming language
1, machine language: Directly with the binary programming, direct control of hardware, need to master the operation of the hardware details
Advantages: High Execution efficiency
Cons: Low development efficiency

2, assembly language: The use of English tags instead of binary instructions to write programs, direct control of hardware, need to master the operation of the hardware details
Advantages: Higher development efficiency than machine language
Cons: Still not changing the nature of the direct operating hardware, execution efficiency is high, but not as high as machine language

3, high-level language: directly in human language to write programs, no longer need to master the operation of hardware details
Compiled C: Similar to the return of Google, after a translation, you can directly take the results of the translation to carry out
Compiled Tool-"compiler"

Advantage: Higher execution efficiency than interpreter
Disadvantage: The development efficiency is lower than the explanatory type

Interpreted Python: Similar and simultaneous interpreting, interpreter equivalent interpreter
Advantage: Development efficiency is higher than the compiled type
Disadvantage: Execution efficiency is less than the compiled type



Execution efficiency from high to Low: machine-"compilation-" compiled-"interpreted type"
Development efficiency from high to Low: explanatory type-"compiled-"-"compilation-" Machine


Second, Python
1. Install the Python interpreter for multi-version coexistence
Set environment variable Path

2. Two ways to run a Python program:
Mode one: Interactive:
Advantages:
Enter a line of code to return the result immediately
Disadvantages:
Unable to permanently save code

Mode two (command line): Python3 D:\test.txt
Advantages: The code is permanently saved in a file, and can be used later

Attention:
①, running a python program does not consider the name of the file suffix, but it is customary to name the suffix of the Python program. py
②, three steps to run a Python program (******)

1. Start the Python interpreter first
2. Read the normal text file in Python program into memory (there is no grammatical concept at this time)
3. The Python interpreter interprets the code that executes just read into memory and begins to recognize the syntax of Python




Third, variable

①, what is a variable
Volume: is a measure/record of a certain characteristic/state in the real world
Change: Refers to the state of the record can be changed

②, why use variables
is to allow the computer to remember the characteristics/state of a thing like a human being (stored in computer memory)
Can be taken out later to use

③, how to use variables
1. Define the syntax of a variable
Age=18
Variable name: Equivalent to a house number, is the only way to access the value
=: The assignment symbol is the memory address of the value bound to the variable name age
Value: Used to represent the state of the

2. Use of variables: reference by variable name

Print (age)

3, Summary: The use of variables rules: first defined, and then by the variable name to refer to

4. Variable name naming rules: variables are used to access the value of the variable, so the variable name should follow a certain specification, to facilitate our identification of the memory value of the function
The premise: the name of the variable name should reflect the status of the value record
salary=3.1
Name= ' Egon '
height=180
Weight=75
①, variable names can only be any combination of letters, numbers, or underscores (case-sensitive)
②, the first character of a variable name cannot be a number
③, cannot name the variable name python keyword


[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']

5. The style of variable name naming:
① Underline (plain lowercase + underline)
AGE_OF_OLDBOY=73 # recommended
② Hump Body
ageofoldboy=73
6: Define a variable, the value of the variable has three characteristics
①id: reflects the position of the value in memory
② types: Different types of values are used to represent/record different states
③value: The data that we store in memory to indicate a state
Age=18
Print (ID (age))
Print (Type (age))
Print (age)

Understanding: Small Integer Pool (* *)
x=100

Y=20

Print (ID (x))
Print (ID (y))
X=12312312321312222222222222222222222222222222222223123123123
Y=12312312321312222222222222222222222222222222222223123123123
Print (ID (x))
Print (ID (y))

V. Interacting with users
VI. Basic data types:
Int
Float
Str
List
Dict
bool



Getting started with Python learning-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.