What is an operator ?
- operator is a Special Symbol which usually represents an action or process on
1.Assignment Operator :
Name itself suggest that assigning value to operand .The in-place operator also known as shortcut operator .Assignment operators can be used on other data types as well .Assignment Operator is simply means a operator which is use to assign a value to variable
Assignment Operators Will help to reduce code and as well as it make code classy
Example x=2 // " = " is equal to is simple assignment operator who assign value 2 into variable x
Generally assignment operators will use in the questions to confuse student
2. Bitwise Operator :
As the name suggests, bitwise operators perform operations on bit level . These operators include
bitwise AND <OR<XOR . bitwise operator cannot be applied to float or double.
Python has six Bitwise operators . Following table will help to understand in well
1.Truth table of Bitwise AND operator :
2.Truth table of Bitwise OR Operator :
3. Truth table of Bitwise XOR :
4.Bitwise NOT:
Shifting operators :
Python supports two shifting operator . they are right shift and left shift . These operators are used
to shifts bits either to the left side or right side.
1 . Left shift Operator " << " = Now to explain left shift consider above example
5<<3 Here Binary Digits of 5 get shift by 3
5 = 0101.0000 (Binary ) get shifted by 3 digits on LHS
0101000.00 = 40 (Decimal )
In left Shit we Gain the bits
2. Right Shift Operator ">>"= 10 Binary Representation (1010) Get shifted By three
Digits on right hand side 10>>3
1.01000 whos decimal value is 1
In Right Shift we Lose the Bits . an if use notice carefully you will notice that shift once to right is divides the number by 2.Hence multiple shifts to the right , result in dividing the number by 2.
Digits on right hand side 10>>3
1.01000 whos decimal value is 1
In Right Shift we Lose the Bits . an if use notice carefully you will notice that shift once to right is divides the number by 2.Hence multiple shifts to the right , result in dividing the number by 2.
Note : to understand shifting operator Consider a decimal point