I. Basic mathematical operators
+ Plus, two objects added, used to calculate the most basic addition, such as the X-sum, equal to 2. (Also, addition can be used to stitch strings)
2.-Minus, you can subtract two numbers and define a negative number alive. 2-1 equals 1.
3.* multiply, you can multiply two numbers, 5*5 equals 25,* multiplication can also be used on a string, you can make a character or string to repeat several times.
4./divide two numbers, doing the division operation.
5.% modulo operation, is to take the remainder.
6.** is used to calculate several times, such as 10 of the 20 10 * * 20 The final result is 100000000000000000000.
7.//, which returns only the quotient, does not return the remainder.
Two. Comparison operator.
= = (equals) to determine whether two objects are equal if equal returns True.
! = (Not equal to) returns True when two objects are not equal.
<> (not equal to) personally think and! = function exactly, is to determine whether two objects are not equal, no difference ~
> (greater than) determines whether a value is greater than another value if it is greater than true.
< (less than) determines whether a value is less than the other value if it is less than true.
>= (greater than or equal) evaluates to True if one value is greater than and equal to another value.
<= (less than equals) evaluates to True if one value is less than and equal to another.
Three. Assignment operator.
= simplest assignment, simply to assign a value to a variable, for example a = 1+2,print a The last result a is equal to 3.
Name = "Suhaozhi", assigning a value to a variable named name.
+ = addition assignment operator, generally used for self-increment, if say a = 0, a+=1 is actually a = a+1.
The-= subtraction assignment operator, which is used to do the self-decrement A-= 1, is actually equivalent to a = A-1.
The *= multiplication assignment operator, a *= 5 represents a = A * 5, each time a is executed automatically.
The/= division assignment operator, a/= 5, represents a = A/5, and each time a is executed, a will automatically divide by 5.
The%=-modulo assignment operation a%=1 is actually equivalent to a = a% 1.
The **= assignment operation a **= 2 is equivalent to a = a**2.
= The assignment operation a//= 2 equals a = A//2.
Four. bit operation.
& Converts decimal to 2, and then each bit is performed with the operation. (This symbol can also be a bitwise AND operator)
For example, 123 and 456 of these two digits of the binary with the operation, that is 123 & 456, the first to convert 123 to binary is 001111011, and then convert 456 to binary 111001000, and the operation begins, the result is 1001000 Convert to 10 binary is 72.
| bitwise OR operator, again, the decimal is converted to binary first, then bitwise OR operation, in the conversion to decimal, and &, except that each bit is or operation.
^ Bitwise XOR operator, the two numbers are converted to binary, two number of the same one is different, this bit is 1, still take 123 and 456 For example, the first is converted to 2, 123=001111011 456=111001000 and then bit-wise, if different, 1, The same is 0, and the final result is that 110110011 is converted to decimal or 135.
<< left to move the operation bit, the number of prepared operations from decimal to binary, to the left a few, the right is not enough place with 0 fill.
Take 123 distance, convert to binary 1111011 if this number is now required to move two bits to the left, then this binary will need to add two 0,123 << 2 as a result 111101100 is converted to decimal or 492.
>> right to move the operation bit, the number of prepared operations from decimal to binary, to the right to move a few, if there is no place to move, from the right to delete a few, still take 123来 example 1111011 right shift two bit after turning into 11110, converted to decimal is 30.
Five. Logical operation.
And and operations, both sides of the true result is true.
Or or operation, both sides as long as the true is true.
Not non, returns True when the condition is not satisfied.
For logical operations, the return value of and and or is not a Boolean value, and the above-mentioned condition is true for ease of understanding.
Add: Using this logical operation, or using () parentheses, the calculation in parentheses is prioritized.
Six. member operators.
A member operator that determines whether the instance has a specified member, such as a list, whether there is a specified element in the tuple, whether there is a specified key in the dictionary, whether the string has the specified character, and so on.
In the specified sequence, there is the element that you want to find, returns True, otherwise false.
Not in and in is reversed, the specified element is not found in the specified sequence, the responsibility returns True, and the returned false is found.
Seven. The identity operator.
Used to compare whether two objects are in the same storage unit.
is two objects of the same memory address, the responsibility to return 1, that is true, otherwise return null.
The memory address of the not-is two object does not have the same responsibility to return 1. True, otherwise returns NULL.
The identity operator, mostly, is whether the two identifiers are the same object and the memory address space is the same.
Add: If you are querying the memory address of an object, you can use the ID () function to fetch the query.
Eight. About the priority of the operation.
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8E/86/wKioL1jDl9rRqZLGAADcPeeZOk0380.png-wh_500x0-wm_ 3-wmp_4-s_3308618275.png "title=" 1036857-20161011090258805-1359487251.png "alt=" Wkiol1jdl9rrqzlgaadcpeezok0380.png-wh_50 "/>
This article is from the "Rebirth" blog, make sure to keep this source http://suhaozhi.blog.51cto.com/7272298/1905386
1.python Basics of common operator collation