A variable and a type
1 variables do not need to be declared
2 type (): Can query data type
3 Data type: none,int,float,bool,string
4 sequence:tuple-fixed Value table, element immutable, list-table, element variable
S1 = (1, 2.2, "3", True) #s1 is a tuple
s2 = [1, 2.2, "3", True] #s2 is a list
s3 = [1,[2.2, "3", True]] #sequence is used as Elem
Element reference
4.1 Subscript Reference: s[(int) index], subscript index starting from 0:
S1[0] = 11
S3[1][0] = 22.22
4.2 Range Reference: s[lower limit: Upper limit: Step length]
Omit lower bound: traverse from start
Omit upper limit: to the last
The upper limit is not included in the upper limit itself
4.3 Trailing reference: s[(int)-index], penultimate index element
5 string
Strings are tuples that can perform related operations on tuples
6 arithmetic
Mathematical operations: +,-,*,/,%,** (exponentiation)
Logical operation: = =,! =, <, <=,, >=, and, or, not, in (determines whether an element is an element of a sequence)
7 Indent
C Language:
if (i > 0)
{
x = 1;
y = 2;
}
Python:
If i > 0:
x = 1
y = 2
Three control processes
1 selection structure
If-elif-else
If condition
Do
Elif condition
Do
Else
Do
2 loop structure (supports continue and break)
2.1 For-in Traversal sequence
for element in sequence
2.2 While
While condition:
Do
Four functions
Format:
def functionname (args)
Do
return args (multiple parameters can be returned)
Python Learning notes 1:python Basics