#python

Functions

Functions let you package up a piece of logic, give it a name, and reuse it. They’re how you organize Python programs into manageable, testable pieces. In the Introduction to Python, we called built-in functions like print() and len(). Now let’s write our own. Defining Functions Use the def keyword: def greet(name): return f"Hello, {name}!" message = greet("Alice") print(message) # Hello, Alice! A function definition has: The def keyword A name (snake_case by convention) Parameters in parentheses A colon, then an indented body An optional return statement (returns None if omitted) Parameters and Arguments Positional arguments def add(a, b): return a + b print(add(3, 5)) # 8 Default values def greet(name, greeting="Hello"): return f"{greeting}, {name}! Read more →

May 18, 2026

Lists

Lists are Python’s most commonly used data structure. They’re ordered, mutable collections that can hold any mix of types. Whether you’re processing API responses, managing user data, or implementing algorithms, you’ll use lists constantly. Creating Lists # Empty list items = [] # List with values numbers = [1, 2, 3, 4, 5] names = ["Alice", "Bob", "Charlie"] mixed = [42, "hello", True, 3.14, None] # From other iterables letters = list("hello") # ['h', 'e', 'l', 'l', 'o'] nums = list(range(1, 6)) # [1, 2, 3, 4, 5] Accessing Elements Lists are zero-indexed. Read more →

May 18, 2026

Dictionaries

Dictionaries are Python’s built-in hash map — they store key-value pairs and give you O(1) lookups by key. If lists are for ordered sequences, dictionaries are for labeled data: user profiles, configuration, API responses, anything where you access values by name rather than position. Creating Dictionaries # Empty dict empty = {} # Dict with values user = { "name": "Alice", "email": "alice@example.com", "age": 28, "active": True } # From a list of tuples pairs = [("a", 1), ("b", 2), ("c", 3)] d = dict(pairs) # {'a': 1, 'b': 2, 'c': 3} # From keyword arguments config = dict(host="localhost", port=5432, debug=True) Accessing Values user = {"name": "Alice", "email": "alice@example. Read more →

May 18, 2026

Classes and Object-Oriented Programming

Classes let you create your own data types that bundle data and behavior together. Instead of passing loose dictionaries around and writing separate functions to operate on them, you define a class that knows what data it holds and what operations make sense for that data. Your First Class class Dog: def __init__(self, name, breed, age): self.name = name self.breed = breed self.age = age def bark(self): return f"{self.name} says: Woof! Read more →

May 18, 2026

Variables and Data Types

In the Introduction to Python, we used variables and saw the basic types like str, int, and float. This tutorial goes deeper — we’ll look at how Python handles types, what mutability means, how to convert between types, and the string and number operations you’ll use constantly. How Variables Work in Python In Python, variables don’t store values directly — they’re names that point to objects in memory. When you write x = 42, Python creates an integer object 42 and makes x point to it. Read more →

April 3, 2026

Introduction

If you’ve been curious about programming but weren’t sure where to start, Python is one of the best first languages you can pick up. It reads almost like English, it doesn’t require a lot of boilerplate to get things done, and it’s used everywhere — from web apps and automation scripts to data science and artificial intelligence. In this tutorial, we’ll get Python installed, write our first program, and explore the building blocks you’ll use in every Python project: variables, data types, and input/output. Read more →

April 3, 2026

Python

Master Python, one of the world's most popular programming languages. From basics to advanced concepts like data science, automation, and web development. Read more →

April 3, 2026

Calling LLM APIs with Python

This tutorial covers calling LLM APIs using Python — the same concepts from Calling LLM APIs with JavaScript, but with Python’s SDK and idioms. If you’ve already read the JavaScript version, this will feel familiar. If Python is your primary language, start here. You should be familiar with What is Generative AI? and Tokens, Context Windows & Model Parameters. Setup Prerequisites Python 3.9+ An OpenAI API key (sign up at platform. Read more →

March 28, 2026

Streaming Responses

When you make a standard LLM API call, you wait for the entire response to be generated before you see anything. For short answers that’s fine, but for longer responses the user stares at a blank screen for seconds. Streaming fixes this by sending tokens to the client as they’re generated, creating the “typing” effect you see in ChatGPT and other AI chat interfaces. This tutorial covers streaming in depth — how it works under the hood, implementation in both JavaScript and Python, and how to integrate streaming into web applications. Read more →

March 28, 2026

Error Handling & Rate Limits

LLM API calls fail. Servers go down, rate limits get hit, tokens exceed context windows, and networks time out. If your application doesn’t handle these failures gracefully, your users get cryptic errors or broken experiences. This tutorial covers the common failure modes, how to detect them, and how to build retry logic that keeps your application running. You should have read Calling LLM APIs with JavaScript or Calling LLM APIs with Python first. Read more →

March 28, 2026