+ 19
What's the use of //= ,&= ,|= ,^= ,>>= ,<<= operators in python?
Please anyone explain me I need clear explanation
33 odpowiedzi
+ 21
Thayani Gathirvelou🇱🇰 here are best explained lesson for bitwise operations have an look over these.
https://www.sololearn.com/learn/4070/?ref=app
https://www.sololearn.com/learn/4072/?ref=app
https://www.sololearn.com/learn/4073/?ref=app
https://www.sololearn.com/learn/4074/?ref=app
https://www.sololearn.com/learn/4076/?ref=app
https://www.sololearn.com/learn/4087/?ref=app
https://www.sololearn.com/learn/4405/?ref=app
https://www.sololearn.com/learn/4086/?ref=app
+ 9
Preity thank you
+ 9
//= is floor division
&= is bitwise AND
|= is bitwise OR
^= is bitwise XOR
>>= is bitwise right shift.
<<= is bitwise left shift.
The equal at the end is because you give a variable at the front and a value after it and the final value will be stored in the variable.
+ 7
Thank you 🙏🙏
+ 7
Ok thank you🙏🙏
+ 6
>> right shift and << left shift
a = 0011 1100
a >>= 2
# a is now 0000 1111
+ 6
Thayani Gathirvelou🇱🇰 check Preity's answer which has links to the various bitwise operators.
+ 6
But anyways, x<<=2 is basically just 5*2^2=20.
+ 6
Dulshan Weeratunge % Modulus: Divides and returns the value of remainder
Examples:-
1)>>>4%3; output 1
2)>>>10%3; Output 1
3)>>>10.5%3 Output 1.5
+ 6
Dulshan Weeratunge= divides and returns🔝
+ 5
I understand addition operator but couldn't understand bitwise operators
+ 5
This article will definitely help you
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_operators.asp
+ 4
Instead of
a = a + 5
Its
a += 5
Exactly the same thing (goes for the other operators as well) Its just to make it easier since variables are updated so often.
+ 4
Prom x=5 x<<=2 how to calculate this
+ 4
Thank you friends
Now i clearly understand
Thank you so much 🙏🙏🙏
+ 4
Ya now iam clear about it
+ 4
You may find answer elucidated in Python in https://www.programiz.com/python-programming/operators
+ 3
Pls explain what is % in Python
+ 3
Thank you all now i clearly understand 🙏🙏🙏🙏
+ 3
👍