+ 3
What is the different between (and , &) and (or, | )
22 Réponses
+ 5
Omar o what do you mean by
5 and 6=>6,tell me
+ 4
And (&&) can mean that both values have to be true while
Or (||) can mean that either one of the values have to be true. If one is true and another is false, then it's still considered as true.
+ 4
and , or= Do logical things.
&,|=used in binary
print(4&3)
4 in binary=100
3 in binary=011
output= 000
where 0=False ,1=True
+ 4
Omar o
print(5 and 6) returns 6 because in a logical test, the value to be returned will be the value evaluated last. (It's written in the link I posted.)
print(5 & 6) will return 4.
+ 3
I'm not sure about Python but in most other languages the word and the symbol for comparing values are almost identical. The only difference is the order it's evaluated. "&" and "|" will be evaluated before "and" and "or".
+ 3
http://thomas-cokelaer.info/tutorials/JUMP_LINK__&&__python__&&__JUMP_LINK/boolean.html
I think this might help and it's similar to what Ben Allen (Njinx) and Dario mentioned.
+ 2
Omar o Sorry I think I misinterpreted your question. I thought you ment the difference between the symbol and the word. silentlearner's answer is correct.
+ 2
(and, or) are logic operators in true/false statement.
Ex: if a<b and a<c :
min=a
(&, |) are "bit by bit" operators. They works with binary representation of two numbers:
Ex: 5 & 6 => 4
In fact 101 & 110 => 100
+ 2
"and" is not born to compare two numbers but two statments.
It returns the last one... only if they are different from zero...
"&" is a binary operator instead.
+ 2
only if the first one is different from zero...
but the code "5 and 6" hasn't got any meaning,
instead "5&6" has
+ 1
but u understand my quistion well.....I really meant this
+ 1
in every time the output will be the number in the right ??(4)
silentlearner
+ 1
Thanks guys😀
0
u mean that there is no deffernce between them??
0
the different between or and |
0
the different between and , &
0
but when do this I will have 6.....why?!
0
Dario 5 and 6 =>6
0
but why the output is 6