This lesson's interactive features are locked, please to keep using them
Binary numbers are just "base 2" numbers. They work the same way as "normal" base 10 numbers, but with two symbols instead of ten.
0 and 10, 1, 2, 3, 4, 5, 6, 7, 8, 9Click to play video
Each digit's place value is double the place to its right. In a 4-digit binary number, the place values are:
For example, 0101 means:
0 eights1 four0 twos1 oneSo 0101 is 5 in decimal.
Try changing the bits:
Interactive example available with JavaScript enabled.
You can write an integer in Python using binary syntax using the 0b prefix:
print(0b0001)
# Prints 1
print(0b0101)
# Prints 5
Leading 0s are often added for visual consistency but do not change the value of a binary number.