PyGCSE Python Lab

Number Bases — Binary, Decimal & Hexadecimal

Learn how to convert between decimal, binary, and hexadecimal, and understand why different number bases are used in computing.

📚 Learning Steps

💡 Study Tips
  • • Read through at your own pace
  • • Try the interactive simulators hands-on
  • • Study the pseudocode — it appears in exams
  • • Quiz yourself before moving on

Step 1: Why Do Computers Use Different Bases?

📖 Theory

Computers operate using binary (base 2) because electronic circuits have two states: ON (1) and OFF (0). But binary is hard for humans to read — long strings of 0s and 1s are error-prone.

The three number bases you need:

Binary (base 2) — digits 0 and 1. Used internally by all digital computers.
Decimal (base 10) — digits 0–9. The everyday number system humans use.
Hexadecimal (base 16) — digits 0–9 and A–F. A compact way to represent binary.

Hexadecimal is used because:

Each hex digit represents exactly 4 binary bits
8-bit byte = just 2 hex digits (e.g., 11111111 = FF)
Memory addresses, colour codes (#FF00AA), MAC addresses all use hex
Much easier for humans to read and type than binary
🎯 Key Points
  • Binary (base 2): used by computers — two states (0/1)
  • Decimal (base 10): used by humans — ten digits (0–9)
  • Hexadecimal (base 16): compact representation — 16 digits (0–F)
  • 1 hex digit = 4 binary bits exactly
  • Hex is used for memory addresses, colour codes, MAC addresses, and error codes
0/5 steps completed