day 003 summary

Use 1.pycharm shortcuts

ctrl + c copy, copy the entire row default

ctrl + v to paste

ctrl + z revocation

ctrl + x shear, shear default entire row

ctrl + a select all

crtl + f to find, select Batch Edit

shift + ctrl + z trans revocation

ctrl + d copy and paste the selected content, the entire row is not selected by default

ctrl + backspace to delete a word

ctrl + y delete the entire line

ctrl + w to select a word

shift + enter wrap

ctrl + shift + r global search

shift + f10 to run on a file

ctrl + shift + f10 to run the current file

ctrl + alt + l formatting code

ctrl + / overall comments

home back to the beginning of the line

end back end of line

2. Variable

variable

All things change in the definition of state

Compositional variables

Variable name (to be described, to accept the value of the variable) of assignments (assignments, the value of the variable pass variable names) values ​​(specific values)

Variable naming specification

Named variables should reflect the state variable values ​​expressed in, remember not to use Chinese

Variable names must underscore combination of alphanumeric, and the first character variable names can not be digital

Keywords can not be declared as a variable name

Two options for defining variables

Hump ​​body

Underline style

3. Constant

Amount does not change (constant names all uppercase), no constant is change convention, in fact, may vary.

4.python Memory Management

Defined variables and running will open up a new memory space to store variable

Reference count (whole team variable value): value of the variable reference number

Garbage collection: reference count of zero when a variable value, triggers the garbage collection mechanism, the variable value will be recovered

Small integer pool: When Python starts, it will automatically define an integer variable between [-5,256], it will not be garbage collection mechanism

The three print form variable

age=10
#打印值
print(age)
#打印内存地址
print(id(age))
#打印数据类型
print(type(age))

6. What is the data type

Data types of variable values ​​made a classification of different categories

Integer float string boolean value dictionary list

7. Digital Type

Integer (int)

1. Role

It represents the person's age, all kinds of numbers, level

2. Definitions

age=18
age=int(18)

3. Use

x = 1
y = 2
print(x + y)
print(x - y)
print(x * y)
print(x / y)
print(x % y)  # 取余
print(x // y) # 取整
print(x ** y) # 幂

Float (float)

1. Role

He represents height, weight, payroll

2. Definitions

salary=3.2
salary=float(3.2)

3. Use

+ - * / % // **

8. String

1. Role

He represents the name of hobbies

2. Definitions

name='nick'
int_str=str(123)

3. Use

Self string comparison logic + *

9. Comment

Single-line comments '' ''

Multi-line comments '' '' ''

Guess you like

Origin www.cnblogs.com/zqfzqf/p/11493416.html