# General help : operator

#1

Hi could someone explain me how to use the operator "^" ?

#2

you mean to the power of:

2 ^ 3 = 8

you need the ** operator:

print 2 ** 3

#3

no like that

return str(bin(n ^ m)).count('1')

#4

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?

#5

thank you for your answer . No I ve ended yesterday the last python chapter i am working alone ...

#6

but if you did the python course you came across the XOR operator here

#7

is this a problem? I thought that it could be useful for all that's why I ve asked here on the general operator..

#8

But its covered in the lesson, and there is plenty documentation. What exactly is your question?

#9

sorry i didn't find any clear answer.. I don't understand how to use this and how this work ( ^ )

#10

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

#11

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 ?

#12

this depends on what the question is

#13

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.