Python β€’ Computer Fundamentals

Computer Fundamentals & Python

Understand how a computer executes code: CPU, RAM, disk, OS, and other components. Plus, learn Python's key characteristics with interactive visuals.

Core Components – Visual Overview

CPU – The Brain Interactive

Click each unit to learn its role in executing instructions.

ALU

Math & Logic

Control Unit

Orchestrates

Registers

Instant access

Cache

L1/L2/L3

RAM – Working Memory Interactive Pyramid

RAM is volatile – your Python variables live here while the program runs. It's ~100x faster than an SSD.

Registers1 cycle256 B
L1 Cache2‑4 cycles64 KB
L2 Cache10‑20 cycles256 KB‑8 MB
L3 Cache30‑50 cycles4‑32 MB
RAM200+ cycles4‑64 GB
Disk/SSDMillions256 GB‑4 TB

Hover over each level – the pyramid narrows at the top: faster but smaller.

Your .py files, Python interpreter, and libraries live on the disk permanently. They are copied to RAM when you run a program.

HDDSSD
Speed~100 MB/s~500–7000 MB/s
NoiseAudible spinningSilent
DurabilityFragileShock resistant

The Operating System manages hardware and provides services to your Python code.

🧡

Process Mgmt

πŸ’Ύ

Memory Allocation

πŸ“

File System

πŸ–₯️

I/O Handling

  • GPU: Graphics & parallel processing (important for AI/ML)
  • Motherboard: Connects all components
  • Network Card: Enables internet and pip install
  • BIOS/UEFI: Starts the computer and initializes hardware

πŸš€ Journey of a Python Program

Click each step to reveal what happens when you run hello.py.

πŸ’Ώ
Load from Disk

Disk β†’ RAM

πŸ”
Parse & Check

Lexer β†’ AST

πŸ“¦
Bytecode

Compile to .pyc

βš™οΈ
PVM Runs

Virtual Machine

🧠
CPU Crunches

Machine code

πŸ–₯️
Output

Result delivered

🐍 Python – Why Developers Love It

πŸ“ Interpreted

No compile step – run instantly.

🧩 Dynamic Typing

No type declarations needed.

πŸ“ High‑Level

Focus on logic, not memory.

πŸ“š Rich Standard Library

Batteries included!

🎯 Object‑Oriented

Everything is an object.

🌍 Cross‑Platform

Write once, run anywhere.

πŸ”€ Indentation Matters

Clean code enforced.

🀝 Open Source

Free & vast ecosystem.

βš–οΈ Python vs Other Languages

⚑ Execution Speed

Higher is better
🐍 Python
50%
β˜• Java
80%
⚑ C++
98%
🌐 JavaScript
72%

πŸ“š Library / Ecosystem

Higher is better
🐍 Python
98%
β˜• Java
75%
⚑ C++
55%
🌐 JavaScript
92%
FeaturePython 🐍Java β˜•C++ ⚑JavaScript 🌐
TypingDynamicStaticStaticDynamic
Best ForAI/ML, Data, WebEnterprise, AndroidGames, SystemsWeb Fullstack
Learning CurveGentleModerateSteepModerate

Practice Problems

1. Check Your Python Version & OS
import sys, platform
print(f"Python: {sys.version}")
print(f"OS: {platform.system()} {platform.release()}")
2. Demonstrate Dynamic Typing
x = 42; print(type(x))
x = "hello"; print(type(x))
3. List Files Using os Module
import os
for item in os.listdir('.'):
    print(item)