Lists: Your Digital Shopping Bag

Imagine you’re going to the grocery store. You write down: milk, eggs, bread, cheese. That’s a list—things in a specific order, one after another.

In Python, a list works exactly the same way. It’s a container that holds multiple items in order. You can put anything in it: numbers, words, even other lists.

Here’s what makes lists powerful: they remember the order. Milk is first, eggs are second, and so on. You can say “give me the first item” or “give me the third item” and Python knows exactly what you mean.

You can also change your list as you go. Forgot to add butter? Add it to the end. Already bought milk? Remove it. Found a great sale on apples? Insert them anywhere you want.

Lists are perfect when order matters and when you have multiple things of the same type. A list of scores. A list of names. A list of temperatures. When you need to keep track of several things in sequence, reach for a list.

Dictionaries: Your Personal Contact Book

Think about how you find someone’s phone number. You don’t look at contact number 1, contact number 2, contact number 3. That would be ridiculous. Instead, you look up their name—“Sarah”—and you immediately get their number.

That’s exactly what a Python dictionary does. It stores pairs: a label and a value. A name and a phone number. A word and its definition. A username and a password.

We call the label a “key” and what it points to a “value.” So in your contact book, “Sarah” is the key, and “555-1234” is the value. You look things up by their key, and Python instantly gives you the value.

Dictionaries are perfect when you need to connect two pieces of information. Student names to their grades. Product names to their prices. Country names to their capitals.

Here’s the key difference from lists: dictionaries don’t care about order. You’re not asking for “the third thing”—you’re asking for “the thing labeled Sarah.” It’s about meaningful labels, not positions.

So remember: use lists when order matters and you have a sequence. Use dictionaries when you need to look things up by name or label.

For Loops: Teaching the Computer to Repeat Itself

Think about what you do when you get a stack of mail. You pick up the first envelope, look at it, decide what to do with it. Then you pick up the second envelope, look at it, decide what to do with it. You keep going until you’ve gone through the whole stack.

That’s not some special task—that’s just how humans naturally handle collections of things. One at a time, all the way through.

For loops are exactly this, but in code. When you have a collection—a list of names, a bunch of numbers, a set of files—you almost always need to do something with each item. It’s one of the most fundamental operations in programming because it mirrors what we do constantly in real life.

Imagine I asked you to write “I will practice coding” one hundred times. You’d probably groan and say “that’s boring and repetitive!” And you’d be absolutely right.

This is exactly the kind of work computers love. Repetitive tasks don’t bore them. But here’s the thing: you don’t want to write the same line of code a hundred times either. That’s where for loops come in.

A for loop is your way of telling the computer: “Do this action for each item in this collection.” For EACH student in the class, print their name. For EACH number in this list, add it to the total. For EACH email in my inbox, check if it’s spam.

The pattern is so common that Python makes it beautifully simple. You literally say “for each thing in this collection” and Python handles the rest—walking through the collection automatically, grabbing each item one at a time.

This isn’t some advanced programming trick. This is the basic, everyday operation of working with collections. For loops turn what we naturally do—process things one by one—into code.

Calling Functions with Variables: Giving Instructions with Details

Remember how we said functions are like small programs? Well, here’s the thing: most programs need information to do their job.

Think about asking someone to make you a sandwich. You don’t just say “make a sandwich” and walk away. You tell them what kind: “Make me a peanut butter and jelly sandwich.” The instruction is “make a sandwich,” but the details—peanut butter and jelly—make it actually useful.

That’s exactly what happens when you call a function with variables. The function is the instruction, and the variables are the details.

Let’s say you wrote a function called calculate_area that finds the area of a rectangle. That function is useless unless you tell it: which rectangle? How wide? How tall? So when you call it, you give it those details: calculate_area(5, 10). You’re saying “calculate the area using width 5 and height 10.”

Here’s where it gets powerful: you can use the same function with different details. calculate_area(3, 7) for one rectangle. calculate_area(12, 8) for another. Same small program, different inputs, different results.

And you can use variables you already have. If you stored my_width = 5 earlier, you can call calculate_area(my_width, 10). Python grabs whatever value is in my_width and passes it along.

This is how functions become flexible and reusable. One function, infinite possibilities—because you’re giving it the specific details it needs each time you call it.

Calling Programs with Variables: Giving Instructions from the Start

When you run a program, you’re not stuck with one fixed behavior. You can give it information right from the beginning—before the first line of code even runs.

Think about when you use a command like “open this file” on your computer. You don’t just say “open”—you tell it which file. The program is “open,” but the detail—the filename—tells it what to work with.

This works the same way with programs you write. When you run a Python program from the command line, you can pass it variables—we call them arguments or parameters.

Let’s say you wrote a program called greet.py that says hello to people. Instead of hardcoding the name inside the program, you can pass it in when you run it: python greet.py Alice. Now the program knows: greet Alice. Run it again with python greet.py Bob, and it greets Bob instead.

Same program, different behavior—controlled from the outside.

This is incredibly powerful. You write the program once, and then you can use it in different situations. One image resizing program can resize any image you point it to. One backup program can back up any folder you specify. You’re making tools, not single-use scripts.

It’s the same idea as calling a function with variables, just at a bigger scale. Your whole program becomes flexible, reusable, and ready for whatever you throw at it.

Basic Types: Different Kinds of Information

When you communicate with people, you use different kinds of information. Sometimes you use numbers: “I have 5 apples.” Sometimes you use words: “My name is Sarah.” Sometimes you answer yes or no: “Is it raining? Yes.”

Python works the same way. It has different types of data because different kinds of information behave differently.

Numbers come in two flavors. Integers are whole numbers—1, 42, -7, 1000. You use these for counting things: students in a class, items in a cart, points in a game. Then there are floats—numbers with decimal points—3.14, 2.5, -0.75. You use these for measurements: temperature, prices, distances.

Strings are text. Any words, sentences, or characters wrapped in quotes. “Hello”, “Sarah”, “123 Main Street”. Even if it looks like a number, if it’s in quotes, it’s text. You can’t do math with “5” + “3”—you get “53”, not 8, because Python treats them as words stuck together, not numbers to add.

Booleans are True or False. That’s it. Just two values. Is the user logged in? True or False. Is the number greater than 10? True or False. These are the yes/no answers that help programs make decisions.

Why does this matter? Because types determine what you can do. You can multiply numbers but not words. You can capitalize text but not numbers. Python needs to know what kind of information you’re working with so it knows what operations make sense.

Understanding types is like knowing the difference between apples and oranges. They’re both fruit, but you handle them differently.

Variables: Labeled Boxes for Information

Imagine you’re organizing your desk. You have a drawer labeled “pens,” another labeled “paper,” and one labeled “important documents.” When you need a pen, you know exactly where to look. When you get new pens, you know exactly where to put them.

Variables work exactly the same way in programming. They’re labeled containers that hold information.

When you write age = 25, you’re creating a box labeled “age” and putting the number 25 inside it. Later, when you need that information, you just say “age” and Python knows exactly what you mean—it goes to that box and gets what’s inside.

The beautiful thing is that variables can change. That’s why we call them variables—they vary. You might start with score = 0, and then as the game progresses, you change it to score = 10, then score = 25. Same box, different contents.

This is how programs remember things. Without variables, your program would have amnesia. It could calculate something, but then immediately forget it. Variables let you capture information—user input, calculation results, settings—and use it throughout your program.

Think of variables as the program’s short-term memory. Good variable names like student_name or total_price make your code readable. Bad names like x or thing1 make it confusing. You’re not just storing data—you’re communicating what that data means.

If/Else: Teaching Programs to Make Decisions

Life is full of decisions. If it’s raining, take an umbrella. Otherwise, don’t. If you have enough money, buy the coffee. Otherwise, skip it.

Programs need to make decisions too, and that’s exactly what if/else statements do.

An if statement asks a question: “Is this condition true?” If the answer is yes, do one thing. If the answer is no, do something else—or do nothing at all.

Let’s say you’re writing a program to check if someone can vote. You ask: if age >= 18. If that’s true, print “You can vote.” Otherwise—the else part—print “You’re too young to vote.” The program looks at the age, makes a decision, and responds accordingly.

This is how programs become smart and responsive. Without if/else, every program would do exactly the same thing every single time, regardless of the situation. With if/else, programs adapt. They can handle different inputs, different conditions, different users.

You can chain decisions together too. If it’s below freezing, wear a heavy coat. Else if it’s chilly, wear a light jacket. Else if it’s warm, wear a t-shirt. Each condition gets checked in order until one matches.

If/else statements are the branching points in your program—where the code path splits based on the reality of the situation. They turn rigid instructions into flexible, intelligent behavior.

Comments: Notes to Your Future Self

Here’s something that surprises beginners: most code is read far more often than it’s written. You write it once, but you—or someone else—might read it dozens of times.

Comments are how you leave notes in your code for human readers. They’re completely ignored by Python. They exist purely to explain what’s happening and why.

Think about recipes. A recipe might say “fold the egg whites gently” and then have a little note: “this keeps the mixture light and airy.” The instruction is “fold,” but the comment explains why you’re doing it that way.

In Python, you write a comment with a hash symbol: # This calculates the tax. Everything after that # on that line is a comment—Python skips right over it.

Here’s when comments are valuable. When the “why” isn’t obvious. When you’re doing something tricky. When you need to remind yourself what a complex section does. Not “x = 5 # set x to 5”—that’s obvious. But “# Using 5 because API limits us to 5 requests per second”—that’s useful context.

The best comments don’t just repeat what the code says—they explain the thinking behind it. They answer questions like: Why this approach? What was the problem this solves? What shouldn’t you change here?