Python Programming

Python taught through runnable work: syntax, functions, data handling, APIs, and real projects from the command line to the web.

29 lessons

Estimated lesson study time: 420 minutes

Lesson estimates are a guide, not a deadline. Allow extra time for practice, projects, and review.

Learn AI & Technology Access gives you full access to all 19 tracks and 552 lessons after sign-up and onboarding. No time limit, paid subscription, or payment card required.

Start Learn AI & Technology Access

Includes three AI Tutor answers across these courses. AI-generated content remains subject to Learn’s monthly allowance.

Track overview

Learn Python through syntax, functions, modules, data handling, APIs, robust programming, and practical projects. Progress from small programs toward reusable command-line and web-facing work, including safe handling of unreliable network calls.

Who this track is for

Beginning programmers and learners who want a Python foundation for later AI or software work.

Before you begin

No prior Python experience is needed for the opening lessons. Be ready to run code, inspect results, and revise programs when tests or errors reveal problems.

What you will work toward

Practice writing organized Python programs that work with data and APIs, handle errors, and use bounded retry behavior.

Complete lesson outline

1. Python Basics

4 lessons

  1. 1.1 Variables, Types, and Expressions

    12 minutes
    • Declare variables and use core types: int, float, str, and bool
    • Combine values with arithmetic and string operations
    • Use f-strings to format output clearly
  2. 1.2 Control Flow and Loops

    13 minutes
    • Branch logic with if, elif, and else statements
    • Iterate over sequences with for and while loops
    • Control loops using break, continue, and range
  3. 1.3 Lists, Dictionaries, and Sets

    14 minutes
    • Store ordered data in lists and access elements by index
    • Map keys to values with dictionaries
    • Use sets for uniqueness and membership tests
  4. 1.4 Comprehensions and Slicing

    13 minutes
    • Build lists and dictionaries with comprehensions
    • Slice sequences to extract subsets
    • Choose comprehensions over loops for concise transformations

2. Functions and Modules

4 lessons

  1. 2.1 Defining and Calling Functions

    13 minutes
    • Define functions with parameters and return values
    • Use default and keyword arguments
    • Explain variable scope inside and outside functions
  2. 2.2 Type Hints and Docstrings

    13 minutes
    • Annotate function signatures with type hints
    • Document functions with clear docstrings
    • Explain how type hints aid tooling and readability
  3. 2.3 Modules, Imports, and Packages

    13 minutes
    • Organize code into modules and import them
    • Use the standard library and third-party packages
    • Explain the difference between a module and a package
  4. 2.4 Virtual Environments and pip

    14 minutes
    • Create an isolated virtual environment for a project
    • Install and pin dependencies with pip
    • Explain why isolation avoids dependency conflicts

3. Data Handling

4 lessons

  1. 3.1 Reading and Writing Files

    14 minutes
    • Open, read, and write text files using context managers
    • Parse CSV data into Python structures
    • Explain why with-blocks safely close files
  2. 3.2 Working with JSON

    13 minutes
    • Serialize Python objects to JSON and back
    • Read JSON from files and API responses
    • Navigate nested JSON structures safely
  3. 3.3 Numerical Computing with NumPy

    15 minutes
    • Create and reshape NumPy arrays
    • Apply vectorized operations for speed
    • Use broadcasting to combine arrays of different shapes
  4. 3.4 Data Analysis with pandas

    16 minutes
    • Load tabular data into a pandas DataFrame
    • Filter, group, and aggregate rows
    • Handle missing values during analysis

4. Working with APIs and the Web

4 lessons

  1. 4.1 Making HTTP Requests

    14 minutes
    • Send GET and POST requests with the httpx library
    • Set headers and parse JSON responses
    • Check status codes and handle failures
  2. 4.2 Managing API Keys and Secrets

    13 minutes
    • Load API keys from environment variables
    • Explain why secrets must never be committed to code
    • Use a dotenv file for local development safely
  3. 4.3 Consuming a REST API

    16 minutes
    • Read API documentation to find endpoints and parameters
    • Send query parameters and authentication headers
    • Handle paginated responses across multiple requests
  4. 4.4 Async Python with asyncio

    16 minutes
    • Use async and await to run concurrent requests
    • Gather multiple tasks with asyncio.gather
    • Explain when concurrency speeds up I/O-bound work

5. Robust Python

4 lessons

  1. 5.1 Exceptions and Error Handling

    14 minutes
    • Catch exceptions with try, except, and finally
    • Raise meaningful errors with custom messages
    • Avoid swallowing errors silently
  2. 5.2 Retries and Rate Limit Handling

    15 minutes
    • Detect transient errors like timeouts and rate limits
    • Implement exponential backoff with jitter
    • Cap retries to avoid infinite loops
  3. 5.3 Logging and Debugging

    14 minutes
    • Replace print statements with the logging module
    • Set log levels to control verbosity
    • Read tracebacks to locate the source of an error
  4. 5.4 Testing Python Code

    15 minutes
    • Write unit tests with pytest
    • Use assertions to verify expected behavior
    • Mock external API calls to test in isolation

6. Building Real Projects

9 lessons

  1. 6.1 Building a Command-Line Tool

    16 minutes
    • Parse command-line arguments with argparse
    • Combine flags, positional arguments, and defaults
    • Print results in a readable format
  2. 6.2 Building a File Organizer

    16 minutes
    • Walk directories and inspect files with pathlib
    • Sort files into folders by extension and date
    • Move and rename files safely with shutil
  3. 6.3 Storing Data with SQLite

    18 minutes
    • Create tables and insert rows with the sqlite3 module
    • Query data with parameterized SQL statements
    • Explain why parameterized queries prevent SQL injection
  4. 6.4 Serving a Web API with FastAPI

    18 minutes
    • Expose a task list behind FastAPI endpoints
    • Validate request bodies with Pydantic models
    • Run the server locally and test the endpoints
  5. 6.5 Scheduling Background Jobs

    15 minutes
    • Run recurring tasks with the schedule library and a simple loop
    • Separate job logic from scheduling for easier testing
    • Explain when to move from in-process scheduling to a dedicated worker
  6. 6.6 Packaging and Distributing Your Project

    16 minutes
    • Structure a project with pyproject.toml and an installable package
    • Define console entry points so a tool runs as a command
    • Build and share a distributable wheel
  7. 6.7 Structured Logging for AI Scripts

    14 minutes
    • Replace print calls with the logging module and log levels
    • Emit structured, machine-readable log records
    • Explain why logs beat prints for debugging real projects
  8. 6.8 Configuration with Environment Variables

    13 minutes
    • Load configuration and secrets from environment variables
    • Provide sensible defaults and validate required settings
    • Explain why secrets stay out of source code
  9. 6.9 Retry and Backoff for API Calls

    14 minutes
    • Wrap flaky network calls with retry logic
    • Apply exponential backoff to avoid hammering a service
    • Explain which errors are safe to retry