Log in from a computer to take this course

You'll need to log in from a computer to start Learn Python 2. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store

The bitwise 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 either number are 1. For example:

a: 00101010 42 b: 00001111 15 ================ a | b: 00101111 47

Note that the bitwise | operator can only create results that are greater than or equal to the larger of the two integer inputs.

So remember, for every given bit in a and b:

0 | 0 = 0 0 | 1 = 1 1 | 0 = 1 1 | 1 = 1


110 (6) | 1010 (10) = 1110 (14)



For practice, print out the result of using | on 0b1110 and 0b101 as a binary string. Try to do it on your own without using the | operator if you can help it.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?