Python assignment and its data type

Python assignment:
Python can assign the same value at the same time:
a=b=c=10
Python assigns different values ​​at the same time:
a,b,c=1,2,3

Python data type:

Immutable data
number (number: int, float, boolean)**

>>> a=True
>>> print(a)
True
>>> type(a)判断类型
<class 'bool'>
>>>del a,c  删除a,c数据 

String:
**tuple: **Example: a=(1,2,3), a[0], a[1], a[2] are 1,2,3 respectively, Can not change its value, can be spliced

Variable data
**list (list): **Example: l1=[1,2,3] can change the value of any data in the list

>>> l1=[1,2,3]
>>> l2=[4,5,6]
>>> l3=l1+l2
>>> l3
[1, 2, 3, 4, 5, 6]
>>>#可拼接

**Set: **Example: s={1,2,3}, index is not supported, value can be changed, and repeated elements will be removed when printing.
**Dictionary: **Example :D={'x':1,'y':2} key-value pair d['x']=1, d['y']=2, unordered storage

Addition, subtraction, multiplication and division

      • /
        / Get a float result
        // get an integer result
        % Remainder
        ** power

Guess you like

Origin blog.csdn.net/weixin_44828960/article/details/108747191