Skip to main content

Where Python Fits

What You'll Learn

Where Python is used, why it's worth learning, and how to think about a Python program before writing a single line of code.

Why Python?

Python is a general-purpose programming language designed to be readable, concise, and practical. It runs everywhere — on your laptop, a Linux server, in the cloud, and inside AI pipelines.

Real companies use Python for:

DomainWhat Python Does
AutomationRename files, send emails, scrape websites, run cron jobs
Data ScienceClean datasets, plot graphs, run statistics
AI / MLTrain models, call LLM APIs, validate outputs
Web APIsBuild REST APIs with Flask or FastAPI
Server OpsHealth checks, log parsing, deployment scripts
DevOpsManage cloud infrastructure (AWS, GCP, Cloudflare)

The Three Questions

Before writing any Python program, ask:

  1. What goes in? — arguments, files, env variables, API calls, user input
  2. What happens? — transforms, checks, filters, calculations
  3. What comes out? — printed output, files written, database rows, API responses, exit codes

This thinking prevents you from writing programs that do mysterious things and are impossible to debug.

A Simple Example: The Pattern

Here is the shape most good Python programs share:

import sys

def main() -> int:
# 1. Get input
name = "world"

# 2. Do work
message = f"Hello, {name}!"

# 3. Produce output
print(message)
return 0

if __name__ == "__main__":
sys.exit(main())

Even for simple scripts, this structure:

  • Makes testing easy (call main() from a test)
  • Makes the entry point clear (if __name__ == "__main__")
  • Returns an exit code so other programs know if it succeeded

Python's Strengths

✅ Readable syntax — close to English
✅ Huge standard library — batteries included
✅ Massive ecosystem — pip install anything
✅ Cross-platform — runs on Linux, Mac, Windows
✅ Great for scripting AND large applications
✅ First-class AI/ML tooling

Python's Weaknesses

⚠️ Slower than C, Go, or Rust for CPU-heavy work
⚠️ Not ideal for mobile apps
⚠️ GIL limits true multi-threading
⚠️ Dynamic typing can hide bugs (use type hints!)

Knowing the weaknesses helps you pick the right tool for the job. Python is excellent for almost everything except raw performance-critical loops.

How Python Code Runs

You write code in a .py file

Python interpreter reads line by line

Each statement is executed immediately

Output appears in the terminal

No compile step needed. This makes Python ideal for scripting and quick experimentation.

Checking Your Python Version

python3 --version

Always use Python 3.8+. Python 2 is obsolete and unsupported.

The Python Philosophy

Run this and read it — it sums up what good Python looks like:

python3 -c "import this"

Key principles:

  • Readability counts. Code is read far more than it is written.
  • Explicit is better than implicit. Don't be clever; be clear.
  • Errors should never pass silently. Handle failures explicitly.
  • There should be one obvious way to do it. Prefer the simple solution.

What's Next

Lesson 2: Installation and Runtime Choices