2.5 Binary Practice

🎯 Learning Goals for This Page
  • Practice converting decimal numbers (base-10) to binary (base-2).
  • Understand how characters (like letters and symbols) are represented using ASCII and Unicode.

Hands-On Binary Practice

The best way to understand binary is to use it. This page is a "digital workbench" for you to practice converting different types of data into the 1s and 0s that a computer understands.

Practice 1: Converting Decimal Numbers to Binary

Remember the method: find the largest power of 2 that fits into your number, subtract it, and repeat with the remainder. For example, to convert 42:

  1. The largest power of 2 that fits in 42 is 32. (42 - 32 = 10 left).
  2. The largest power of 2 that fits in 10 is 8. (10 - 8 = 2 left).
  3. The largest power of 2 that fits in 2 is 2. (2 - 2 = 0 left).
  4. So, 42 is 32 + 8 + 2. This means the binary number is 101010.

Use the interactive Python converter below to check your work and practice with different numbers. Run the program and enter any number you like!

Python 3Initializing...
Loading code editor...
Program output will appear here...

Practice 2: How Text Becomes Binary

Computers handle text using a standard called ASCII (and its modern successor, Unicode). Every character on your keyboard has a unique number assigned to it. For example:

  • The letter 'A' is number 65.
  • The letter 'a' is number 97.
  • The symbol '!' is number 33.

The computer then just converts that number into binary. So, 'A' is stored as the binary for 65, which is 1000001.

Run the interactive tool below. Type any single character and press Enter to see its secret binary code!

Python 3Initializing...
Loading code editor...
Program output will appear here...
The Universal Translator

This two-step process—turning every piece of information into a number, and then turning that number into binary—is how computers can represent everything in the world using only 1s and 0s.

Interactive Sandbox

Use this space to practice writing code and complete the "Your Turn" activities above.

Python 3Initializing...
Loading code editor...
Program output will appear here...