Introduction to Computing
Understanding how computers work, binary numbers, and logic gates
Understanding how computers work, binary numbers, and logic gates
Welcome to your first step in understanding computer science!
Computers are everywhere - in your phone, your car, even your microwave! But have you ever wondered how they actually work?
Fun Fact: The computer or phone you're using right now is performing billions of calculations every second, all using just two digits: 0 and 1!
In this lesson, we'll peel back the layers and discover the fundamental principles that make all computers work, from the simplest calculator to the most powerful supercomputer.
Before we start, try to think: What do you think is the most basic thing a computer can do? (Hint: It's simpler than you might think!)
At its core, a computer is a machine that processes information. But let's break that down into four essential functions:
Computers receive information from the outside world through input devices.
Examples:
The CPU (Central Processing Unit) performs calculations and makes decisions based on instructions (programs).
What happens during processing:
Computers store information for immediate use (RAM) or long-term storage (hard drive/SSD).
Types of storage:
After processing, computers present results through output devices.
Examples:
Think about using a calculator app on your phone. Can you identify each of the four functions?
Imagine trying to build a machine that can tell the difference between 10 different voltage levels. It would be complex and prone to errors! Instead, computers use just two states:
Binary is reliable! It's easy for electronic circuits to distinguish between "definitely on" and "definitely off", but hard to reliably detect the difference between, say, 3.2V and 3.3V.
Uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Each position represents a power of 10:
Uses 2 digits: 0, 1
Each position represents a power of 2:
Decimal | Binary | Pattern Notes |
---|---|---|
0 | 0000 | All off |
1 | 0001 | Rightmost on |
2 | 0010 | Second position |
3 | 0011 | 2 + 1 |
4 | 0100 | Third position |
5 | 0101 | 4 + 1 |
8 | 1000 | Fourth position |
15 | 1111 | All on (max for 4 bits) |
Notice how binary numbers follow a pattern: the rightmost digit alternates every number (0,1,0,1...), the second digit from right alternates every 2 numbers (0,0,1,1,0,0,1,1...), the third every 4 numbers, and so on!
Enter a number between 0-255
Enter only 0s and 1s
The number 10 in binary (1010) would be stored in 1 byte (8 bits) of computer memory. In computing, we often use 8-bit chunks called bytes!
1. Convert these decimal numbers to binary:
7
0111
12
1100
20
10100
2. Convert these binary numbers to decimal:
1010
10
11011
27
100000
32
3. Challenge Question:
What's the largest number you can represent with 8 bits (8 binary digits)?
11111111 in binary = 255 in decimal
This is why many computer values have a maximum of 255!
Logic gates are the fundamental building blocks of all digital circuits. They perform simple logical operations on binary inputs (0 or 1) to produce a binary output. Every complex operation your computer does is built from millions of these simple gates!
The AND gate outputs 1 only when ALL inputs are 1. Think of it like a series circuit - both switches must be ON for the light to turn on.
Real-world analogy:
A car will start only if you have the key AND you press the brake pedal.
A | B | A AND B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
The OR gate outputs 1 when ANY input is 1. Think of it like a parallel circuit - either switch can turn on the light.
Real-world analogy:
A door will open if you use a key OR enter the correct code.
A | B | A OR B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
The NOT gate (also called an inverter) flips the input - 0 becomes 1, and 1 becomes 0.
Real-world analogy:
A "Do Not Disturb" sign - when it's ON, you're NOT available.
A | NOT A |
---|---|
0 | 1 |
1 | 0 |
These three simple gates (AND, OR, NOT) can be combined to create ANY computation! Every calculation your computer does, every video game, every app - they all come down to billions of these gates working together at incredible speed.
Outputs 1 only when ALL inputs are 1
Given A = 1 and B = 0, what is the output of:
A AND B = ?
0 (both must be 1)
A OR B = ?
1 (at least one is 1)
NOT A = ?
0 (flip the value)
Everything in a computer's memory is stored as binary numbers - text, images, videos, programs - everything! Let's explore how this works.
A single binary digit (0 or 1)
The smallest unit of data
8 bits grouped together
Can store one character (like 'A') or a number from 0-255
Unit | Size | Real-World Example |
---|---|---|
1 Byte | 8 bits | A single character |
1 KB | 1,024 bytes | A short email (text only) |
1 MB | 1,024 KB | A high-quality photo |
1 GB | 1,024 MB | About 250 songs (MP3) |
1 TB | 1,024 GB | About 250,000 songs |
Each character has a number code (ASCII/Unicode)
Stored directly as binary
Each pixel's color as RGB values
Sound waves sampled as numbers
You might wonder why we use 1024 instead of 1000. It's because 1024 = 2^10, which fits perfectly with binary! This is why sometimes hard drive manufacturers (who use 1000) and computers (which use 1024) show different sizes for the same drive.
Let's see how much you've learned! Answer these questions to check your understanding.
1. Why do computers use binary instead of decimal?
2. What is the decimal value of binary 1010?
3. Which logic gate outputs 1 only when both inputs are 1?
4. How many bits are in one byte?
All the complex things computers do - from playing videos to running AI - are built from these simple foundations: binary numbers and logic gates. You now understand the fundamental principles that power every digital device!
Now that you understand how computers work at the most basic level, you're ready to learn how to give them instructions through programming!
Continue to Programming Fundamentals โ