1.lists are medium brackets.for example age = [2,3,56,9]
2.dictionary tables are brackets for example name={‘xiaoming’:30, ‘huahua’:80,‘gender’:‘kk’}
there are two ways to index numeric values in a dictionary.
one is an index key in the forn of name [‘xiaoming’],
the other is to use get() function, such as name.get(‘gender’),
which can be assignde if there is no key in get , such as name.get(‘age’,20)
the name dictionary adds an age key and assigns 20
3.tuples are parentheses, and no subscript index can be used to modify values, for example big =(1,2,1,1,1)
lists can be modified by index values
5.use ‘{0:.2f}’.format(variable) for data formatting, which means keeping two decimal digits
6.unequal symbols are ‘!=’
7.method of keeping integers only
(1) ‘//’ is retain integer and retain high precision for example 10//4.0 >>>2.0
(2) the math.floor integer part is the value of the coordinate axis near the left
(3) math.trunc is the reserved value approcaching zero
(5) round is rounded(四舍五入)
8. other digits correspond to decimal values
0o stands for octal 0x for hexadecimal 0b for binary, 8421 method inbinary system
9. the decimal system is converted to other systems as shown below
9. using decimal module to make the numerical value more precise
10. ‘’’ ‘’’ marks define a description document,
- common use of signle and double quotation marks are used as follows
- commonly used backslash and its meaning for example \n mean line feed,\t mean enter four spaces \a mean bell
- in the statement we can add r so that what we declare is what we export so as follows
15 some common operations of strings, as shown below
16 when a value needs to be changed frequently, it can be defined as a list and then coverted into a string
17 a method of segmenting strings and judging the first character and end it。 as follows
- find an index of the location of an element
19.Examples of Format Use
- the types in the array are consistent , and the data types in the list can be different
21.‘in ’ special words can determine whether a data is in the list or not as follows
- some other uses
- in the replacement of elements in the list, the principle of selecting values in the list is to leave the values in front and the final values should not be ,such as[1;2], the values at position 2 shuold be rounded off
- addition an element to a list and extending a list of list as shown below
- list support in-siu changes,but string do not support in-situ changes,in-situ changes are changes,after nonin-situ changes are changed, the original object needs to be reassigned to save the changed amount
- multiple objects point to the same reference, modify a variable and other variables point to the reference change
- if copy assignment is used it will not change at the same time following chart
summary