o‘zing o‘rgan
Computer Literacy and Safety Lesson 1 / 15
Pingvi

How a computer works

Processor, memory, disk, operating system; bits and bytes; binary

Chapter 1. Safe in the digital world 15 minutes Python 4 questions

A computer — whether a phone, a laptop or a server — is made of the same parts:

Part Job Analogy
Processor (CPU) runs instructions, computes the cook
Memory (RAM) what's running right now — fast, but lost when powered off the kitchen table
Disk (SSD/HDD) stores files permanently the fridge and shelves
Operating system (OS) runs everything: Windows, Android, Linux, macOS, iOS the head chef

When your phone "slows down", usually RAM is full (too many apps open) or the disk is full.

Bits and bytes

Inside a computer everything — text, pictures, music — is made of 0s and 1s. A single 0 or 1 is a bit. 8 bits make a byte.

print(bin(13))              # 13 in binary
print(int("1101", 2))       # from binary to decimal
print(2 ** 8)               # how many different values fit in 1 byte
# Output: 0b1101
# Output: 13
# Output: 256
Unit Size Roughly fits
1 byte 8 bits one Latin letter
1 KB (kilobyte) 1024 bytes a short text message
1 MB (megabyte) 1024 KB one phone photo (2–5 MB)
1 GB (gigabyte) 1024 MB ~1 hour of video
1 TB (terabyte) 1024 GB thousands of films

💡 Internet speed is usually measured in bits (Mbit/s), file size in bytes (MB). 100 Mbit/s is about 12.5 MB a second. That's why "a 100 MB file doesn't download in 1 second on 100-megabit internet".

Practice Python

Turn a byte count into a readable size: under 1024 — bytes, otherwise KB, MB or GB (one decimal place):

500 B
1.5 KB
5.0 MB
2.0 GB
main.py Ctrl+Enter — run
input() data
Write code and press "Run". Loading Python takes a few seconds the first time.
Show solution
def hajm(bayt):
    if bayt < 1024:
        return f"{bayt} B"
    for birlik in ["KB", "MB", "GB"]:
        bayt /= 1024
        if bayt < 1024 or birlik == "GB":
            return f"{bayt:.1f} {birlik}"

for b in [500, 1536, 5_242_880, 2_147_483_648]:
    print(hajm(b))

Check yourself

Question 1 / 4

Which memory loses its data when the computer is switched off?

Choices

Question 2 / 4

How many bits are in a byte?

Choices

Question 3 / 4

What number is 101 in binary?

Choices

Question 4 / 4

About how many MB per second does 100 Mbit/s internet download?

Choices