+ 5

What does "|" sign meaning in python?

19th Apr 2021, 6:39 PM
Kakai
+ 4
| is a bitwise or It operates on binary digits For instance if you had the number 10 and 13 and you ORed them. 10 = 0000 1010 in binary (as byte) 13 = 0000 1101 in binary (as byte) The result would be 15 = 0000 1111 in binary (as byte) A | B | result 0 | 0 | 0 0 | 1 | 1 1 | 0 | 1 1 | 1 | 1 if either of the bit are 1 the resulting bit is 1, otherwise 0. print(10 | 13) # outputs 15
19th Apr 2021, 7:55 PM
ChaoticDawg
+ 3
"|" means 3 things in Python: Either a bitwise-OR operator, or a set-combine operator, or "OR" in regex.
21st Apr 2021, 4:34 PM
Calvin Thomas
+ 2
It's a bitwise operator and it's functionality is similar to the logical || operator. If either of the bits value are 1 then it returns 1 otherwise 0. It's logical operator || countersign works by returning an integral boolean of 1 if either of the expression is truthy otherwise 0
19th Apr 2021, 6:51 PM
Mirielle
+ 2
1- a union operator which used to combine two sets to form a new one containing elements in either = {}.union() method 2 - in regular expressions it means or
21st Apr 2021, 7:19 AM
Alaa Aldeen Shammr