1. A variable is a storage space with a name
2. Variable name ( Or function name ) Naming rules :
A. Variable names can only be made of letters 、 Numbers 、 Underline composition
B. Variable names can only start with letters or underscores ( Cannot start with a number )
C. The variable name cannot be the same as the keyword in the system
D. Variable names are case sensitive
E. Variables are defined before they are used
3. Assignment symbol :a=b ——> take b The value of is assigned to a( The right value d To the variable on the left )
4.Python Medium 33 Key words :
True None True class continue def finally for from
nonlocal lambda is return try while and as
assert del elif else global if import not or pass
with yield break except in rais
How to write it : for i in range(num):
The loop body
How to write it : while( Conditions ):
The loop body
How to write it : if( Conditions ):
Execution event
How to write it : if( Conditions ):
Execution event 1
else:
Execution event 2
《 Add 》:random Random function
Format :random(a,b)——> stay a To b Between random numbers , The range of generated numbers is a—(b-1), That is, the minimum is a, The maximum is b-1
A.a and b ——> And operation ,a And b Logical values are all true , The result is true , Otherwise, the result is false
B.a or b ——> Or operations ,a And b One of the logical values is true , That's true , Otherwise, the result is false
C.not a ——> Reverse operation , Yes a The logical negation of ,a Is true and false after operation , On the contrary, it is true
A.a>b ——> Greater than operator ,a Greater than b The result is true , conversely ,a Less than b The result is false
B.a<b ——> Less than operator ,a Less than b The result is true , conversely ,a Greater than b The result is false
C.a==b ——> Equals operator ,a be equal to b The result is true , conversely ,a It's not equal to b The result is false
3 . Mathematical operators (+、-、*、/、%)
Format : List name =[“ value 1”, “ value 2”, “ value 3”, “ value 4”, “ value 5”, “ value 6”]
Indexes ——> Describes the number of element values in the list , Index from 0 Numbered starting
Extraction of values ——> List name [ Indexes ], The list name plus the corresponding position index of the extracted elements in the list , This value can be extracted and used
Format : List name [ Indexes ]= Changed value ——> Assign the value to be changed to the corresponding position in the list
Format : List name .clear()——> After performing this operation , All values in the list will be cleared
Format : List name .insert( Location , Elements )——> Insert the element in the specified position in the list
Format :len( List name )——> After performing this operation , You can get the number of elements in the list ( length )
Format : Specify elements in List name ——> Determine whether the specified element is in the list , If yes, the return value is true , Otherwise, the return value is false
Format : List name .pop( Indexes )——> After performing this operation , The index value at the corresponding position in the list will be deleted
if else while range( Sequence functions ) random( Random function ) and or
not clear( clear list ) insert( List element insert ) len( List length calculation )
in pop( The list specifies that the element is deleted ) True False