+ 5

"|" sign in python

What does "|" sign meaning in python?

19th Apr 2021, 6:39 PM
Kakai
Kakai - avatar
5 Respostas
+ 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
ChaoticDawg - avatar
+ 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
Calvin Thomas - avatar
+ 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
Alaa Aldeen Shammr - avatar