+ 19

What's the use of //= ,&= ,|= ,^= ,>>= ,<<= operators in python?

Please anyone explain me I need clear explanation

12th Jun 2020, 1:38 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
33 odpowiedzi
+ 9
Preity thank you
12th Jun 2020, 1:56 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
+ 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.
12th Jun 2020, 1:58 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 7
Thank you 🙏🙏
12th Jun 2020, 1:50 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
+ 7
Ok thank you🙏🙏
12th Jun 2020, 2:02 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
+ 6
>> right shift and << left shift a = 0011 1100 a >>= 2 # a is now 0000 1111
12th Jun 2020, 1:48 PM
Slick
Slick - avatar
+ 6
Thayani Gathirvelou🇱🇰 check Preity's answer which has links to the various bitwise operators.
12th Jun 2020, 2:01 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 6
But anyways, x<<=2 is basically just 5*2^2=20.
12th Jun 2020, 2:02 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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
13th Jun 2020, 6:16 AM
narayanaprasad
narayanaprasad - avatar
+ 6
Dulshan Weeratunge= divides and returns🔝
13th Jun 2020, 6:17 AM
narayanaprasad
narayanaprasad - avatar
+ 5
I understand addition operator but couldn't understand bitwise operators
12th Jun 2020, 1:43 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
13th Jun 2020, 12:49 AM
ReDaDDi
ReDaDDi - avatar
+ 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.
12th Jun 2020, 1:40 PM
Slick
Slick - avatar
+ 4
Prom x=5 x<<=2 how to calculate this
12th Jun 2020, 2:00 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
+ 4
Thank you friends Now i clearly understand Thank you so much 🙏🙏🙏
12th Jun 2020, 2:10 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
+ 4
Ya now iam clear about it
12th Jun 2020, 2:20 PM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
+ 4
13th Jun 2020, 3:04 AM
narayanaprasad
narayanaprasad - avatar
+ 3
Pls explain what is % in Python
13th Jun 2020, 4:30 AM
Dulshan Thakshila Weeratunge
Dulshan Thakshila Weeratunge - avatar
+ 3
Thank you all now i clearly understand 🙏🙏🙏🙏
13th Jun 2020, 6:20 AM
Thayani Gathirvelou🇱🇰
Thayani Gathirvelou🇱🇰 - avatar
+ 3
👍
9th Jun 2021, 8:40 AM
Tharul Nejana
Tharul Nejana - avatar