day03 summary

Recalling the last lesson

Classification of programming languages

Machine language

High efficiency,

Low development efficiency

Assembly language (OS / plug-in)

Development of high efficiency

Low efficiency

High-level language

Interpreted language

Development of high efficiency

Low efficiency

Compiled language

High efficiency

Low development efficiency

Network bottleneck effect

Latency network far greater than the execution time of the program, the execution time of the program appear to be unimportant, the program does not require networking lower execution time, the use of an interpreted language, but as the operating system needs to perform this procedure efficiency

Python implementation of the program in two ways

Interactive (jupyter)

Write a line to explain his party

Command line (pycharm)

cmd input file path python +

Use pycharm shortcuts

ctrl + c Default Replication entire row

shift + ctrl + z trans revocation

ctrl + x Cut (copy and delete selected content), the default cut the entire line.

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

home back to the beginning of the line

end back end of line

ctrl + shift + home select a code block

ctrl + f Find: Select Batch Edit (green check point), you can also write regular expressions

ctrl + shift + r Global (the entire project) search, you can replace

ctrl + / overall comments

shift + f10 to run on a file

ctrl + shift + f10 to run the current file

ctrl + alt + l is adjusted to make the code standard style

Shortcuts modify the path: file -> settings -> keymap

Variables and constants

What is Programming -> write a bunch of files -> control variable I in the direction you want to change P -> O

What is variable

Capacity: recording status in the real world, so that the computer can like people to identify things in the world

Change: the state of the real world that will change the

Compositional variables

Variable name (described; receiving variable values)

Assignment symbol (assignment, the variable value is passed to the variable name)

Variable values ​​(specific numerical values)

Specification of variable names

1. Variable names must be descriptive sense

2. The variable name from the number / letter / underscores, and can not begin with a number

3. Keyword can not be named

Definitions of the variables in two ways (the code run from top to bottom, if the same variable name is executed later)

1. underscore formula (python in the formula must be underlined)

2. hump body

You can use variables to define the English word without quotation marks is the variable name

constant

1. The amount does not change (the variable name to all uppercase)

2. No change is conventional, the actual energy change

Three print form python memory management and variables

How to form variables in the computer

1. The variable is the concept python interpreter provided only when running python

2. Define the variables and running, it will open up a new memory space to store variable

python garbage collection mechanism

Reference count (for variable value): value of the variable number of times quoted

# age = 1000  # 1000的引用计数为1
# age1 = age  # 1000的引用计数为2
# del age  # delete删除age,1000的引用计数为1
# print(age1)
# del age1 # 1000的引用计数为0

Garbage collection

When the value of a variable reference count is 0, it will trigger a garbage collection mechanism, the variable value will be recovered, release the memory occupied by the variable value

Small integer pool

When python boot, will automatically define an integer variable between [-5,256], their memory has been written is dead

# age = 10
# age1 = age
# del age
# del age1

Logically speaking cited 10 counts to zero triggers garbage collection, but because 10 is a small integer pool, so it will not trigger a garbage collection mechanism

The latter will bind to the global interpreter lock gil

== defined variables will open up new memory space ==

Variable name == == for receiving variable values

pycharm the scope of expanding the pool of small integers

Three printing form variables

age = 10

print(age)

print(id(age))

print(type(age))

type of data

Variables: variable name = variable value (specific value)

Data types of variable values ​​were classified

Digital Type

Role: Description Age / ID card number, etc.

Defined way

age = 30

age =int(30)

Instructions

And four operations% (remainder) // (rounded) ** (exponentiation)

Other mathematical symbols import cmath use

Float

Role: height description, salary, etc.

Defined way

salary = 3.2

salary = float(3.2)

Cast

height = float(4)

print(height)

salary2 = int (3.7) # will not be rounded

rounding

print(round(3.7))

Instructions

And as integer

Logical comparison

x=1

y = 2

print(x>y)

String type

Role: Description Name / gender, etc.

Defined way

name = 'caiqilong'

name = "cai"

Three strings within quotation marks wrap

Instructions

Add, Multiply

str1 = 'nick'

str2 = 'handsome'

print(str1+' '+str2)

Strings and numbers can not be summed

print(str1*10)

Note

Single-line comments

, In addition to explain the failure of the code also allows

Multiple selections press ctrl + / may be converted into a plurality of single-line comments

Multi-line comments

Triple quotes

Guess you like

Origin www.cnblogs.com/-406454833/p/11494072.html