Hi could someone explain me how to use the operator "^" ?
you mean to the power of:
2 ^ 3 = 8
you need the
print 2 ** 3
no like that
return str(bin(n ^ m)).count('1')
if you post under 1. python syntax, i didn't assume you where working on bit wise operators. Does this involve an exercise? If so, do you have the url?
thank you for your answer . No I ve ended yesterday the last python chapter i am working alone ...
is this a problem? I thought that it could be useful for all that's why I ve asked here on the general operator..
But its covered in the lesson, and there is plenty documentation. What exactly is your question?
sorry i didn't find any clear answer.. I don't understand how to use this and how this work ( ^ )
so what is in the exercise:
The XOR (^) or exclusive or operator compares two numbers on a bit level and returns a number where the bits of that number are turned on if either of the corresponding bits of the two numbers are 1, but not both.
a: 00101010 42 b: 00001111 15 ================ a ^ b: 00100101 37
wasn't clear, but you did pass it?
the exclusive or operator returns 1 if either is one, but not both:
0^1 = 1 1^0 = 1 0^0 = 0 1^1 = 0
thank you @stetim94 for your answer, it s very clear now ..
i found the solution on github but before pass the exercice i wanted to understand ..
if I have other question , can I ask here ?
this depends on what the question is
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.