The Illustrated Guide to Local AI

Deck

Python

Cards for the Python programming language.

Python cover
print
print Common
Code · Base Set
CommonCodeBase Set
Power 2 · Danger 1 · Speed 10 · Difficulty 1

Description

It makes the computer show words on the screen so you can see what it is thinking. You type the words inside the brackets, and they appear right in front of you.

Analogy

It is like a town crier shouting a message so everyone can hear it.

Example

print("Hello")

Flavour

The golden voice that speaks the truth into the light.

Effect

It makes the computer show words on the screen so you can see what it is thinking. (POWER 2, DANGER 1, SPEED 10, DIFFICULTY 1)

Learn this in chapter 12 →
variable
variable Common
Code · Base Set
CommonCodeBase Set
Power 3 · Danger 1 · Speed 10 · Difficulty 1

Description

It stores a piece of information so you can use it later. You give it a name, put a value inside, and call it by that name whenever you need it.

Analogy

It is like a jar in your pantry with a label on it, holding sugar or flour for later use.

Example (name = 'Mazen')

name = "Alice"

Flavour

The quiet vessel that holds the essence until the moment of casting.

Effect

It stores a piece of information so you can use it later. (POWER 3, DANGER 1, SPEED 10, DIFFICULTY 1)

Learn this in chapter 12 →
string
string Common
Code · Base Set
CommonCodeBase Set
Power 3 · Danger 1 · Speed 8 · Difficulty 1

Description

It holds words or sentences inside quotes so the computer can read them. You use it to store names, messages, or any text you want to keep.

Analogy

It is like writing a note on a slip of paper and putting it in a sealed envelope.

Example

print("hello")

Flavour

The golden thread that binds the spoken word to the machine's memory.

Effect

It holds words or sentences inside quotes so the computer can read them. (POWER 3, DANGER 1, SPEED 8, DIFFICULTY 1)

Learn this in chapter 12 →
number
number Common
Code · Base Set
CommonCodeBase Set
Power 3 · Danger 1 · Speed 8 · Difficulty 1

Description

It holds a count or a measurement so the computer can do math with it. You write a whole number or a decimal, and the machine treats it as a value to add, subtract, or compare.

Analogy

It is like placing a single gold coin on a scale to measure its weight.

Example

42

Flavour

The golden seed that grows into every calculation.

Effect

It holds a count or a measurement so the computer can do math with it. (POWER 3, DANGER 1, SPEED 8, DIFFICULTY 1)

Learn this in chapter 12 →
list
list Uncommon
Code · Base Set
UncommonCodeBase Set
Power 3 · Danger 1 · Speed 8 · Difficulty 2

Description

It holds many items in a specific order. You can add things, remove them, or look at what is inside. It is the most common way to store data.

Analogy

It is like a numbered shelf where every item sits in its own slot.

Example

my_list = [1, 2, 3]

Flavour

The golden ledger that remembers every promise in order.

Effect

It holds many items in a specific order. (POWER 3, DANGER 1, SPEED 8, DIFFICULTY 2)

Learn this in chapter 4 →
dictionary
dictionary Uncommon
Code · Base Set
UncommonCodeBase Set
Power 4 · Danger 1 · Speed 8 · Difficulty 2

Description

It stores pairs of labels and values so you can look up information instantly. You give it a key, and it hands you the matching value. It is the most common way to organize data in Python.

Analogy

It is like a contacts book where you look up a name to find the phone number.

Example

my_dict = {"name": "Alice", "age": 30}

Flavour

The golden ledger that binds every name to its true value.

Effect

It stores pairs of labels and values so you can look up information instantly. (POWER 4, DANGER 1, SPEED 8, DIFFICULTY 2)

Learn this in chapter 4 →
for loop
for loop Uncommon
Code · Base Set
UncommonCodeBase Set
Power 4 · Danger 1 · Speed 7 · Difficulty 2

Description

It repeats a task for every item in a list, one after another. You tell it what to do, and it handles each piece without you having to count them.

Analogy

It is like handing a tray of cookies to each guest at a party, one by one.

Example

for item in items: print(item)

Flavour

The endless procession that serves every soul in the hall.

Effect

It repeats a task for every item in a list, one after another. (POWER 4, DANGER 1, SPEED 7, DIFFICULTY 2)

Learn this in chapter 4 →
while loop
while loop Uncommon
Code · Base Set
UncommonCodeBase Set
Power 4 · Danger 2 · Speed 5 · Difficulty 2

Description

It repeats a task over and over as long as a condition remains true. It stops only when that condition becomes false.

Analogy

It is like stirring a pot of soup until it cools down, stopping only when the temperature drops.

Example

while temperature > 100: stir()

Flavour

The eternal rhythm that binds the spell until the truth changes.

Effect

It repeats a task over and over as long as a condition remains true. (POWER 4, DANGER 2, SPEED 5, DIFFICULTY 2)

Learn this in chapter 4 →
if
if Uncommon
Code · Base Set
UncommonCodeBase Set
Power 3 · Danger 1 · Speed 8 · Difficulty 2

Description

It checks a condition and runs code only if that condition is true. It acts like a gatekeeper that decides which path to take based on what it sees.

Analogy

It is like a traffic light that turns green for cars going north and red for cars going south.

Example

if x > 10: print("Go")

Flavour

The bronze gate that opens only for the worthy.

Effect

It checks a condition and runs code only if that condition is true. (POWER 3, DANGER 1, SPEED 8, DIFFICULTY 2)

Learn this in chapter 12 →
function
function Rare
Code · Base Set
RareCodeBase Set
Power 4 · Danger 1 · Speed 5 · Difficulty 2

Description

It is a named set of steps you write once and use many times. You give it a name, put the instructions inside, and call it whenever you need those steps done.

Analogy

It is like a recipe card in a cookbook, where you write the steps once and cook the dish whenever you want.

Example

def greet(): print("Hello")

Flavour

The golden sigil that repeats the spell without speaking it again.

Effect

It is a named set of steps you write once and use many times. (POWER 4, DANGER 1, SPEED 5, DIFFICULTY 2)

Learn this in chapter 12 →
import
import Uncommon
Code · Base Set
UncommonCodeBase Set
Power 3 · Danger 1 · Speed 8 · Difficulty 2

Description

It brings a tool from another person's library into your own workshop. You ask for a specific helper, and it appears ready to work.

Analogy

It is like borrowing a specialized wrench from a neighbor's garage.

Example (import os)

import math

Flavour

The silent courier who carries the master's tools across the threshold.

Effect

It brings a tool from another person's library into your own workshop. (POWER 3, DANGER 1, SPEED 8, DIFFICULTY 2)

Learn this in chapter 9 →
pip install
pip install Uncommon
Code · Base Set
UncommonCodeBase Set
Power 4 · Danger 2 · Speed 5 · Difficulty 2

Description

It downloads a helper tool from the internet so your program can use it. You type the name, it fetches the package, and then your code can call it.

Analogy

It is like ordering a specific spice from a catalog so your kitchen can cook a new recipe.

Example (pip install requests)

pip install requests

Flavour

The courier who brings the missing ingredient to the alchemist’s table.

Effect

It downloads a helper tool from the internet so your program can use it. (POWER 4, DANGER 2, SPEED 5, DIFFICULTY 2)

Learn this in chapter 9 →
virtual environment
virtual environment Rare
Code · Base Set
RareCodeBase Set
Power 4 · Danger 1 · Speed 5 · Difficulty 3

Description

It creates a private space for one project so its tools do not mix with others. You can install different versions of things without breaking the rest of your computer.

Analogy

It is like a separate kitchen drawer for just one recipe, keeping the spices from getting mixed up.

Example

python -m venv my_project

Flavour

The sealed glass jar that holds only the ingredients for this single spell.

Effect

It creates a private space for one project so its tools do not mix with others. (POWER 4, DANGER 1, SPEED 5, DIFFICULTY 3)

Learn this in chapter 9 →
comment
comment Common
Code · Base Set
CommonCodeBase Set
Power 1 · Danger 1 · Speed 1 · Difficulty 1

Description

It is a note for people, not for the machine. The computer skips it entirely, so it does nothing to the code. It helps you remember why you wrote something.

Analogy

It is like a sticky note on a recipe that says "add salt later."

Example (# this downloads the model)

# add salt later

Flavour

The quiet whisper that guides the hand, unseen by the eye.

Effect

It is a note for people, not for the machine. (POWER 1, DANGER 1, SPEED 1, DIFFICULTY 1)

Learn this in chapter 12 →
f-string
f-string Common
Code · Base Set
CommonCodeBase Set
Power 3 · Danger 1 · Speed 8 · Difficulty 2

Description

It builds a sentence by dropping values into empty slots. You write the words, put braces where the blanks are, and Python fills them in for you. It makes text easy to read and quick to change.

Analogy

It is like a fill-in-the-blank worksheet where you write the answers in the spaces.

Example

print(f"Hello, {name}!")

Flavour

The golden script that binds the spirit to the word.

Effect

It builds a sentence by dropping values into empty slots. (POWER 3, DANGER 1, SPEED 8, DIFFICULTY 2)

Learn this in chapter 12 →
range
range Common
Code · Base Set
CommonCodeBase Set
Power 3 · Danger 1 · Speed 8 · Difficulty 2

Description

It creates a sequence of numbers for you to count through. You use it to tell a loop how many times to run. It is the ladder you climb step by step.

Analogy

It is like a ladder with exactly the right number of rungs for your climb.

Example

range(10)

Flavour

The golden ladder that rises from the earth to the sky.

Effect

It creates a sequence of numbers for you to count through. (POWER 3, DANGER 1, SPEED 8, DIFFICULTY 2)

Learn this in chapter 4 →
len
len Common
Code · Base Set
CommonCodeBase Set
Power 2 · Danger 1 · Speed 10 · Difficulty 1

Description

It counts how many items are in a list or string. You ask it, and it gives you the number. It is the simplest way to know the size of your data.

Analogy

It is like counting the apples in a basket without taking them out.

Example

len("hello")

Flavour

The golden scale that weighs the weight of words.

Effect

It counts how many items are in a list or string. (POWER 2, DANGER 1, SPEED 10, DIFFICULTY 1)

Learn this in chapter 4 →
file
file Uncommon
Code · Base Set
UncommonCodeBase Set
Power 3 · Danger 1 · Speed 5 · Difficulty 2

Description

It opens a document so you can read what is written inside or add new words to it. You must close it when you are done, just like shutting a book.

Analogy

It is like opening a library book to read a page, then closing it to keep the pages safe.

Example

open("story.txt", "r")

Flavour

The golden key that unlocks the silent archives of memory.

Effect

It opens a document so you can read what is written inside or add new words to it. (POWER 3, DANGER 1, SPEED 5, DIFFICULTY 2)

Learn this in chapter 5 →
try/except
try/except Uncommon
Code · Base Set
UncommonCodeBase Set
Power 4 · Danger 1 · Speed 5 · Difficulty 2

Description

It attempts a risky action, and if that action fails, it catches the error instead of crashing. This allows the program to handle mistakes gracefully and continue running.

Analogy

It is like wearing a safety harness while climbing a ladder, so a slip does not mean a fall.

Example

try: print(1/0) except ZeroDivisionError: print("Cannot divide by zero")

Flavour

The golden net that catches the falling star before it shatters the floor.

Effect

It attempts a risky action, and if that action fails, it catches the error instead of crashing. (POWER 4, DANGER 1, SPEED 5, DIFFICULTY 2)

Learn this in chapter 12 →
class
class Rare
Code · Base Set
RareCodeBase Set
Power 4 · Danger 1 · Speed 5 · Difficulty 3

Description

It is a blueprint for making many similar things. You define the shape once, and then stamp out as many copies as you need. It keeps your code tidy and reusable.

Analogy

It is like a cookie cutter that stamps out identical cookies from dough.

Example (class Dog: ...)

class Dog:

Flavour

The golden mold that shapes the clay of creation.

Effect

It is a blueprint for making many similar things. (POWER 4, DANGER 1, SPEED 5, DIFFICULTY 3)

Learn this in chapter 12 →

← All decks