Hello, Python
Code runs one instruction at a time. In this first lesson, the only thing we need to care about is how to send a message back to the screen.
print() is the simplest way to do that. It takes a value, turns it into something the computer can display, and then shows it on its own line. That makes it a useful starting point whenever you want to test an idea quickly.
print("A message for the person using the program")Run this once before changing anything. Then replace the words between the quotation marks and notice that the structure of the program stays the same while the output changes.
Write a print() statement that introduces you by name.
print("Hello, I am Maya!")Pause after running the example and explain each line in your own words. Notice what the program reads, what it stores, and what it prints, then make one small change and run it again to see exactly what changed.
Practice
Work through the same idea a few times so it starts to feel familiar. Begin by copying the example, then make the single change the instruction asks for, and finally explain to yourself why the result changed.
Your program should be an exact copy of the runnable example above, including any indentation.Keep the program structure the same. A correct attempt has one changed value and one short comment about its effect.# I expect: ...
# Then run the program and compare that comment with the real output.A correct solution uses the central idea from this lesson, prints one result, and stays small enough to trace line by line.Values and types
Programs work with different kinds of information: text, whole numbers, decimals, and true-or-false values. The important part here is not just that these kinds exist, but that Python treats them differently.
When you see a value in code, it helps to ask two questions: what is the value, and what type of value is it? That habit becomes useful later when a piece of code behaves differently from what you expected.
"text" # a string
42 # an integer
True # a booleantype() tells us what kind of value Python sees. This is one of the simplest debugging tools you can use when a result looks strange, because it shows whether Python is handling text, numbers, or a boolean.
Use type() to inspect the decimal number 3.14.
print(type(3.14))Pause after running the example and explain each line in your own words. Notice what the program reads, what it stores, and what it prints, then make one small change and run it again to see exactly what changed.
Practice
Work through the same idea a few times so it starts to feel familiar. Begin by copying the example, then make the single change the instruction asks for, and finally explain to yourself why the result changed.
Your program should be an exact copy of the runnable example above, including any indentation.Keep the program structure the same. A correct attempt has one changed value and one short comment about its effect.# I expect: ...
# Then run the program and compare that comment with the real output.A correct solution uses the central idea from this lesson, prints one result, and stays small enough to trace line by line.
Variables
Variables give useful names to values, so we can use them again later. This is one of the main ideas in programming: instead of repeating the same thing over and over, give it a label and refer back to it.
Think of a variable as a label on a box. The label is what you write in code, and the value is what the label points to. When the value changes, the name stays the same unless you assign something new to it.
name = "Ada"
print(name)Store two details, then print them together. This shows that a program can combine separate pieces of information into one sentence or one result.
Create a variable named city, give it a value, and print it.
city = "Lagos"
print(city)Pause after running the example and explain each line in your own words. Notice what the program reads, what it stores, and what it prints, then make one small change and run it again to see exactly what changed.
Practice
Work through the same idea a few times so it starts to feel familiar. Begin by copying the example, then make the single change the instruction asks for, and finally explain to yourself why the result changed.
Your program should be an exact copy of the runnable example above, including any indentation.Keep the program structure the same. A correct attempt has one changed value and one short comment about its effect.# I expect: ...
# Then run the program and compare that comment with the real output.A correct solution uses the central idea from this lesson, prints one result, and stays small enough to trace line by line.
Strings
Strings are text, and text is the easiest place to start practicing with real program output. Once you can store and change text, you can build prompts, labels, messages, and user-facing responses.
F-strings let us place a variable directly inside a sentence. They are useful because they keep the final message readable without needing to join many small pieces together.
name = "Sam"
message = f"Welcome, {name}!"Use a string method to change text to uppercase. Methods are little actions attached to a value, and this is your first chance to see how Python can transform text without replacing the original idea.
Make a variable named food and print it in uppercase.
food = "pizza"
print(food.upper())Pause after running the example and explain each line in your own words. Notice what the program reads, what it stores, and what it prints, then make one small change and run it again to see exactly what changed.
Practice
Work through the same idea a few times so it starts to feel familiar. Begin by copying the example, then make the single change the instruction asks for, and finally explain to yourself why the result changed.
Your program should be an exact copy of the runnable example above, including any indentation.Keep the program structure the same. A correct attempt has one changed value and one short comment about its effect.# I expect: ...
# Then run the program and compare that comment with the real output.A correct solution uses the central idea from this lesson, prints one result, and stays small enough to trace line by line.Lists
Lists keep ordered items together. They are useful when the order matters, when you want to walk through several values, or when you want to add and remove items over time.
The first item has position 0, which can feel strange at first. That numbering choice is common in programming, so it is worth getting comfortable with it early.
colors = ["red", "blue"]
first_color = colors[0]Add an item to the end of a list with append(). This is a common pattern when you are collecting results step by step instead of writing the whole list at once.
Create a list of two animals, append one more animal, then print the list.
animals = ["cat", "dog"]
animals.append("otter")
print(animals)Pause after running the example and explain each line in your own words. Notice what the program reads, what it stores, and what it prints, then make one small change and run it again to see exactly what changed.
Practice
Work through the same idea a few times so it starts to feel familiar. Begin by copying the example, then make the single change the instruction asks for, and finally explain to yourself why the result changed.
Your program should be an exact copy of the runnable example above, including any indentation.Keep the program structure the same. A correct attempt has one changed value and one short comment about its effect.# I expect: ...
# Then run the program and compare that comment with the real output.A correct solution uses the central idea from this lesson, prints one result, and stays small enough to trace line by line.
Dictionaries
Dictionaries store related values under descriptive keys instead of positions. This makes them a strong fit when you already know the name of the thing you want and do not want to count through a list to find it.
You can think of a dictionary like a small lookup table. The key is what you ask for, and the value is what you get back.
profile = {"name": "Maya"}
print(profile["name"])Add a new key and value to a dictionary. This shows that dictionaries are not fixed structures; you can expand them as your program learns more information.
Create a dictionary for a book with a title key, then print its title.
book = {"title": "Dune"}
print(book["title"])Pause after running the example and explain each line in your own words. Notice what the program reads, what it stores, and what it prints, then make one small change and run it again to see exactly what changed.
Practice
Work through the same idea a few times so it starts to feel familiar. Begin by copying the example, then make the single change the instruction asks for, and finally explain to yourself why the result changed.
Your program should be an exact copy of the runnable example above, including any indentation.Keep the program structure the same. A correct attempt has one changed value and one short comment about its effect.# I expect: ...
# Then run the program and compare that comment with the real output.A correct solution uses the central idea from this lesson, prints one result, and stays small enough to trace line by line.