A simple operation
>>>
2
>>> 2-1
1
>>> 2*3
6
>>> 2/1
2.0
>>> 5%4 <==== Returns the remainder of a division
1
>>> 2**2 <==== Power Sub-party
4
>>> 5//2 <==== about the pick-up, take only the whole number of parts
2
>>> 5==5
True
>>> 5!=4 <==== about not equal to
True
>>> 5>4
True
>>> 4<5
True
>>> 5>=5
True
>>> 4<=4
True
About binary operations
Operator Description Instance
& Bitwise AND Operator 10&50 The result is 2 if A is 00001010 b 00110010 means that the same bits in A and B are true and 1
| The bitwise OR operator 10|50 results in a result of 58 if A is 00001010 B for 00110010 that is the same bit in A and B as long as one is true, it is 1.
^ Bitwise XOR operator 10^50 The result is 1=56 if A is 00001010 B for 00110010 that is the same bit in A and B as long as there is a true is true is 1, all true is False represents 0, all false is False representative 0
>> Right Move operator If A is 00001010, the result is 00000101 for 5, according to the right shift.
<< left move operator if A is 00001010 and left one, the result is 00010100 for 5.
logical operators
Operator description
and Boolean "and" if X is False,x and Y returns false
or boolean "or", if X is true, it returns true
Not Boolean "non", if X is true, it returns false
Member operators
Operator
Inch
Not in
Example
The number 1:
name=[' Alex ', ' Rain ']if ' Jack ' in Name:print ("Pengchun was Handsome") Else:print ("Pengchun is very handsome")
Results Pengchun is very handsome
The number 2:
name=[' Alex ', ' Rain ']if ' Alex ' in Name:print ("Pengchun was Handsome") Else:print ("Pengchun is very handsome")
Results Pengchun is handsome
Identity operator
Is
is not
Example:
The number 1
The If Type (3) is Int:print ("Pengchun is Handsome") results in Pengchun is handsomethe number 2 if Type (3) was not List:print ("p Engchun is handsome ") results Pengchun is handsome
About simple operations, binary operations, logical operators, member operators, identity operators