This topic covers Python fundamentals from installation to practical programming patterns. Whether you are writing your first script or solidifying your understanding of core concepts, these lessons will give you a thorough grounding in the language that powers data science, web development, automation, and countless other domains.
This topic provides hands-on coverage of:
- Getting Started: Installation, REPL, virtual environments, and tooling
- Core Language: Variables, data types, operators, expressions, and control flow
- Functions: Defining, calling, and composing functions with Python's rich parameter system
- Data Structures: Lists, tuples, dictionaries, sets, and comprehensions
- Strings: Formatting, methods, regular expressions, and Unicode
- Object-Oriented Programming: Classes, inheritance, polymorphism, dunder methods, and dataclasses
- Modules and Packages: Importing, structuring projects, and the standard library
- File I/O and Exceptions: Reading/writing files, handling errors, and context managers
- Pythonic Style: Idioms, best practices, and patterns that distinguish fluent Python code
- Programming — Familiarity with general programming concepts (variables, control flow, functions)
No prior Python experience is required. If you can read pseudocode and understand what a variable or a loop does, you are ready.
Python Basics — Learning Path
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ ┌──────────────┐ ┌──────────────────┐ ┌────────────────────────┐ │
│ │ 01 Getting │──▶│ 02 Variables & │──▶│ 03 Operators & │ │
│ │ Started │ │ Data Types │ │ Expressions │ │
│ └──────────────┘ └──────────────────┘ └────────────┬───────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────────┐ ┌────────────────────────┐ │
│ │ 06 Data │◀──│ 05 Functions │◀──│ 04 Control Flow │ │
│ │ Structures │ │ │ │ │ │
│ └──────┬───────┘ └──────────────────┘ └────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────────┐ ┌────────────────────────┐ │
│ │ 07 Strings │──▶│ 08 OOP Basics │──▶│ 09 OOP Advanced │ │
│ │ │ │ │ │ │ │
│ └──────────────┘ └──────────────────┘ └────────────┬───────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────────┐ ┌────────────────────────┐ │
│ │ 12 Exceptions│◀──│ 11 File I/O │◀──│ 10 Modules & │ │
│ │ │ │ │ │ Packages │ │
│ └──────┬───────┘ └──────────────────┘ └────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────────┐ │
│ │ 13 Standard │──▶│ 14 Pythonic │ │
│ │ Library │ │ Idioms │ │
│ └──────────────┘ └──────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
| # | Title | Difficulty | Key Content |
|---|---|---|---|
| 01 | Getting Started | ⭐ | Installation, REPL, virtual environments, pip, first program |
| 02 | Variables and Data Types | ⭐ | Assignment, int, float, str, bool, None, type conversion |
| 03 | Operators and Expressions | ⭐ | Arithmetic, comparison, logical, bitwise, walrus operator |
| 04 | Control Flow | ⭐ | if/elif/else, for, while, range, match/case, loop patterns |
| 05 | Functions | ⭐ | Defining, parameters, return values, scope, lambda, closures |
| 06 | Data Structures | ⭐ | Lists, tuples, dicts, sets, comprehensions, unpacking |
| 07 | Strings and Text Processing | ⭐ | Methods, formatting, f-strings, regex basics, Unicode |
| 08 | OOP Basics | ⭐⭐ | Classes, instances, attributes, methods, init, properties |
| 09 | OOP Advanced | ⭐⭐ | Inheritance, polymorphism, dunder methods, dataclasses, ABCs |
| 10 | Modules and Packages | ⭐ | import, name, packages, namespace, third-party libraries |
| 11 | File I/O | ⭐ | open(), read/write, context managers, CSV, JSON, pathlib |
| 12 | Exception Handling | ⭐⭐ | try/except/finally, custom exceptions, exception chaining |
| 13 | Standard Library Essentials | ⭐ | collections, itertools, functools, datetime, os, sys, re |
| 14 | Python Idioms and Best Practices | ⭐⭐ | PEP 8, EAFP vs LBYL, generators, decorators, context managers |
Follow the lessons sequentially from 01 through 14. Each lesson builds on concepts introduced in the previous one:
- Environment Setup (Lesson 1): Get Python installed and running
- Language Fundamentals (Lessons 2-4): Variables, operators, and control flow form the backbone of every program
- Functions (Lesson 5): Learn to organize code into reusable blocks
- Data Structures and Strings (Lessons 6-7): Master Python's built-in collections and text processing
- Object-Oriented Programming (Lessons 8-9): Model real-world concepts with classes
- Project Organization (Lesson 10): Structure code into modules and packages
- I/O and Error Handling (Lessons 11-12): Interact with the file system and handle failures gracefully
- Mastery (Lessons 13-14): Leverage the standard library and write idiomatic Python
Verify your Python installation:
python3 --version
# Python 3.12.x (or newer)Set up a dedicated virtual environment for exercises:
# Create a virtual environment
python3 -m venv ~/.venvs/python-basics
# Activate it
source ~/.venvs/python-basics/bin/activate # macOS / Linux
# .\.venvs\python-basics\Scripts\activate # Windows
# Confirm
which python
python --versionExample code for each lesson is available in examples/Python_Basics/.
- Python (Advanced) — Decorators, generators, metaclasses, async/await, and performance tuning
- Programming — Language-independent programming concepts
- Data Science — Applying Python to data analysis and visualization
- Testing and QA — pytest, test-driven development, and quality assurance
License: Content licensed under CC BY-NC 4.0