Lesson 1 · Unit 01
Counting in two
Bits, bytes, binary and hex
What you practise
- Place values, binary and hex, bytes, what n bits can count,
0b/0xandbin/hex
Try a question from this lesson
Pick one
A light switch has two positions. How many different on/off patterns can three switches in a row show?
Correct answer
8
Why
Each extra switch doubles the count: 2 × 2 × 2 = 8. It is not 3 × 2 = 6, because the switches combine, they do not just add. A computer bit is one such switch.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Places worth 8, 4, 2, 1
A bit is 0 or 1. In a binary number each place is worth double the one to its right: 1, 2, 4, 8, 16...
So 1011 is 8 + 0 + 2 + 1 = 11. Python reads binary written with a 0b prefix, and bin() shows a number in binary.
print(0b1011) # 11
print(bin(11)) # 0b1011Concept
Hex: shorthand for bits
Long rows of bits are hard to read, so programmers write them in hex, base 16. The digits are 0-9, then a-f for ten to fifteen.
One hex digit is exactly four bits, so a byte is always two hex digits: ff is 1111 1111, which is 255. Python uses the 0x prefix.
print(0xff) # 255
print(0x10) # 16, not 10
print(hex(255)) # 0xff10 more exercises in the app
- 3× type the answer
- 3× multiple choice
- 1× fill the blanks
- 1× match the pairs
- 1× order the lines
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.