Raja NI Posted April 9, 2020 Share Posted April 9, 2020 Hi x=5 y=3 why x^=y => 6 why x l=y => 7 why x &= y => 1 Link to comment Share on other sites More sharing options...
Funce Posted May 14, 2020 Share Posted May 14, 2020 What's important with these operators, is that they perform Binary Arithmetic. So to understand it, you need to understand X and Y in Binary. X (101)= 5 Y (011) = 3 ^= Is the python bitwise XOR operator, and the result of XORing X and Y is the following X ^= Y (XOR) (110) = 6 Similarly |= is the Bitwise OR operator, and so X |= Y (OR) (111) = 7 And &= is the bitwise AND opereator, and so X &= Y (AND) (001) = 1 Each operation is applied to each digit in sequence. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now