python basic operators

Basic operators

rounding a // b

a% b modulo

power of a ** ba b

the left and right sides of a == b operator determines whether the same value

a! = b determines whether the value of the left and right sides of unequal operator

a> ba> = ba <ba <= b Comparison operators

Incremental assignment operator

a + = 1 corresponds to a = a +1

a * = 2 corresponds to a = a * 2

...

Chain assignment

x = y =z =1

Cross assignment

a = 1 b =2

a, b = b, a result is a = 2 b = 1

Decompression assignment

l1 = [1, 2, 3, 4, 5]

a, b, c, d, * _ = l1 * _: receiving element may overflow

The result is 1, 2, 3, 4,

 

logic operation

With or

Priority: ()> not> and> or

and: if there is a lion does not meet the conditions, the whole equation are False

or: As long as there is a formula in line with the conditions, the whole equation are True

not: negation

Guess you like

Origin www.cnblogs.com/chenyangdada/p/11795601.html