Students just finished a full SQL journey - JOINs, window functions, CTEs, a hotel capstone dataset. They were dangerous with PostgreSQL. Confident. A little smug, even.
Then I told them we were switching to Python.
The energy in the room shifted. SQL felt structured - you ask a question, the table talks back. Python felt like a blank page. No table. No schema. Just a cursor blinking at you.
Week 1 was about changing that feeling. Here's exactly what we did.
First Question I Asked the Room
Before touching a keyboard, I asked everyone: "What do you think code actually is?"
Answers ranged from "instructions for a computer" to "I have no idea but it looks scary in movies."
Here's what I told them:
Code is just a very precise way of talking to a computer. The computer is not smart - it does exactly what you say, nothing more. Your job as a programmer is to be clear enough that it doesn't get confused.
That framing - the computer is not smart, you have to be precise - removes a lot of the intimidation. You're not learning to be a genius. You're learning to communicate clearly.
Setting Up: Python + VS Code
We installed Python 3 and VS Code. This part takes longer than it should with a full class (there's always one laptop that does something unexpected), but we got everyone running.
First file. First line of code:
print("Hello, Nairobi!")
Output:
Hello, Nairobi!
Simple. Silly, even. But I could see people smile when their computer actually said something back. That moment matters more than people realise - it's the first time the machine responds to them.
Variables: The Labelled Box Analogy
The first real concept: variables.
My analogy: imagine a variable is a labelled box. You put something inside the box, you write a name on the outside, and later you can pick up the box by its name and use whatever's inside.
name = "Amina"
age = 25
city = "Nairobi"
print(name) # Amina
print(age) # 25
print(city) # Nairobi
Then we showed them that the box can be updated - the label stays the same but the content changes:
score = 40
print(score) # 40
score = 85
print(score) # 85
Someone asked: "So the old value just disappears?" Exactly. The box only holds one thing at a time. The new value replaces the old one.
Data Types: Not All Boxes Are The Same
Here's where it gets interesting. Python cares about what kind of thing you put in the box. We covered the four core types:
| Type | Example | What it is |
|---|---|---|
int |
42 |
Whole numbers |
float |
3.14 |
Decimal numbers |
str |
"Amina" |
Text (always in quotes) |
bool |
True / False
|
Yes or no — that's it |
students = 30 # int
average_score = 74.5 # float
school_name = "Lux Academy" # str
is_open = True # bool
print(type(students)) # <class 'int'>
print(type(average_score)) # <class 'float'>
print(type(school_name)) # <class 'str'>
print(type(is_open)) # <class 'bool'>
The type() function became a favourite immediately. Students started wrapping everything in it just to check. Good habit, honestly.
The Mistake That Catches Everyone (And I Mean Everyone)
Mixing types without converting them first. This one gets everybody:
age = input("How old are you? ")
next_year = age + 1
print(next_year)
Error:
TypeError: can only concatenate str (not "int") to "str"
The confusion on their faces was real. "But I typed a number!"
Here's the thing: input() always returns a string, even if the user types 25. Python received the text "25", not the number 25. You have to tell it explicitly to treat it as a number:
age = int(input("How old are you? "))
next_year = age + 1
print("Next year you will be", next_year)
Output (if user types 25):
Next year you will be 26
This lesson - Python doesn't assume, you have to be explicit - is one of the most important mindset shifts for beginners. And once they've hit this error, they never forget it.
Type Conversion: Speaking Python's Language
We covered the three conversion tools they'll use constantly:
# String to integer
price_text = "250"
price = int(price_text)
print(price + 50) # 300
# String to float
weight_text = "72.5"
weight = float(weight_text)
print(weight * 2) # 145.0
# Number to string (for building sentences)
items = 5
message = "You have " + str(items) + " items in your cart"
print(message) # You have 5 items in your cart
The last one - str() for building messages - connected immediately because we also introduced f-strings as a cleaner alternative:
name = "Brian"
balance = 4500
print(f"Hey {name}, your M-Pesa balance is KES {balance}")
Output:
Hey Brian, your M-Pesa balance is KES 4500
f-strings are technically Session 6 material but the students loved them so much I let it slide. Sometimes you follow the energy.
input(): Making Programs Interactive
input() is where things start feeling like actual software.
name = input("What is your name? ")
print(f"Welcome to the system, {name}!")
We built a small interactive program on the spot - a basic student registration prompt:
name = input("Enter student name: ")
age = int(input("Enter age: "))
course = input("Enter course: ")
print("--- Student Record ---")
print(f"Name: {name}")
print(f"Age: {age}")
print(f"Course: {course}")
Sample Run:
Enter student name: Wanjiku
Enter age: 23
Enter course: Data Engineering
--- Student Record ---
Name: Wanjiku
Age: 23
Course: Data Engineering
This was the session highlight. Students went from writing print("Hello") to building something that takes input and structures a response - in one session. The room felt different after that exercise.
Practice Problems We Ran
A few of the exercises we worked through - try them yourself:
Easy:
# 1. Store your name, age, and city in variables. Print them.
# 2. Ask the user for two numbers and print their sum.
# 3. Use type() to check what type "3.14" is before and after float() conversion.
Medium:
# A kiosk receipt printer - ask for item name and price, print a formatted receipt
item = input("Item name: ")
price = float(input("Price (KES): "))
quantity = int(input("Quantity: "))
total = price * quantity
print(f"\n--- Receipt ---")
print(f"Item: {item}")
print(f"Price: KES {price}")
print(f"Qty: {quantity}")
print(f"Total: KES {total}")
Challenge:
# Temperature converter - ask user for Celsius, convert to Fahrenheit and Kelvin
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
kelvin = celsius + 273.15
print(f"{celsius}°C = {fahrenheit}°F = {kelvin}K")
What I Noticed Teaching This Session
The SQL background helped more than I expected. Students who came from our SQL class already understood the idea of data having types - a VARCHAR column vs an INT column. Python's str and int felt familiar. That prior context is genuinely useful.
input() is the best motivator at this stage. The second a program asks them a question and responds to their answer, it stops feeling like a tutorial and starts feeling like real software. Use it early and often.
The TypeError from input() is a gift. Don't avoid it -engineer it. Make students hit that error deliberately, read it, understand it, and fix it themselves. Error messages are information, not judgement.
What's Coming in Week 2
Next session: operators and conditionals. We'll teach Python to make decisions - if, elif, else - and build programs that respond differently depending on the input.
A little teaser for the students:
balance = float(input("Enter your M-Pesa balance: "))
if balance >= 1000:
print("You're good to send money.")
elif balance >= 100:
print("Low balance — top up soon.")
else:
print("Insufficient balance.")
Suddenly Python isn't just printing things - it's thinking. See you next week.
Try It Yourself
All you need to follow along:
- Download Python 3
- Download VS Code
- Create a file called
week1.py, paste any example above, and run it
No setup complexity. No cloud accounts. Just Python and a text editor.
I'm a data trainer in Nairobi running a full data programme - Python foundations → Data Science or Data Engineering specialisations. I write weekly about what we covered, what worked, and what surprised me. Follow along or drop your questions in the comments , especially if you're teaching or learning Python from scratch.

Top comments (0)