The last time I wrote about this session, I had a group of ex-SQL students staring at a blank Python file like it owed them money. This time it's a fresh group - some have never opened a terminal before, one guy, Kevin, tells me he installed VS Code that morning and hasn't touched it since. Same nerves. Same blinking cursor. Same "so... do I just start typing?"
I've decided to do something different with this one. Instead of just telling you what happened in the room, I'm going to walk you through the actual session - the way I taught it. Open a file called session1.py, keep it next to this article, and type every example yourself. Don't copy-paste. Type it, break it, fix it. That's the whole point.
print() - Talking to the World
Everything starts here. print() is Python's way of showing you something on the screen - you tell it what to say, it says it.
print("Hello, world!")
Hello, world!
Text goes in quotes. Numbers don't need them. And if you separate two things with a comma, Python prints them both with a space in between:
print("My name is", "Amina")
print(42)
print("Python is", "great")
My name is Amina
42
Python is great
Kevin's first line wasn't "Hello, world" though. It was print("I installed VS Code and I'm still alive"). Fair enough.
Variables - Labelled Boxes
A variable is a labelled box where you store a piece of information. Instead of retyping "Amina Wanjiku" every time, you store it once and reuse the label.
name = "Amina Wanjiku"
age = 24
city = "Nairobi"
print(name, "is", age, "years old and lives in", city)
Amina Wanjiku is 24 years old and lives in Nairobi
Here's the bit that always makes people pause - updating a variable using itself:
score = 50
score = score + 10
print("Score:", score)
Score: 60
Read it right to left. Python calculates the right side first (50 + 10), then stores the result back in score. It's not algebra, it's an instruction: "take what's in the box, change it, put it back."
Data Types - What Kind of Thing Is It?
Python needs to know what kind of data it's holding before it decides what to do with it. You can add two numbers. You can join two pieces of text. You cannot mix them.
number_a = 5 # int
number_b = "5" # str - this is the text "5", not the number
print(number_a + number_a) # 10 - adds numbers
print(number_b + number_b) # 55 - joins strings
10
55
This is the single most common beginner mistake, and it catches literally everyone at some point - usually the first time they use input(), because input() always hands you back a string, even if the user typed a number. If you need a number, you convert it:
text_number = "42"
real_number = int(text_number)
print(real_number + 8) # 50
50
int(), float(), and str() convert between types. One trap worth knowing early: converting a float to an int drops the decimal, it doesn't round.
print(int(9.9)) # 9, not 10
9
input() - Letting the User Talk Back
So far Python has only been talking to you. input() lets the user talk to Python. When Python hits it, the program pauses, waits for someone to type something and press Enter, then hands that back to you - as a string, always.
name = input("What is your name? ")
print("Hello,", name)
What is your name? Brian
Hello, Brian
Notice the space before the closing quote in "What is your name? " - without it, the user's answer runs straight into the question with no gap. Small detail, makes a real difference.
For numbers, wrap the whole thing:
age = int(input("How old are you? "))
print("Next year you'll be", age + 1)
How old are you? 24
Next year you'll be 25
Arithmetic - Python as a Calculator
Python does everything a calculator does, plus a couple of operators most people haven't met before.
a = 15
b = 4
print("Addition:", a + b) # 19
print("Division:", a / b) # 3.75
print("Floor division:", a // b) # 3 - drops the decimal
print("Modulus:", a % b) # 3 - the remainder
print("Power:", a ** b) # 50625
% - modulus - is the one that gets the most questions. It gives you the remainder after dividing. It sounds abstract until you use it to check whether a number is even:
number = 42
print(number % 2 == 0) # True - no remainder, so it's even
True
f-strings - The Clean Way to Print
Once you're mixing several variables into one message, commas get messy fast. f-strings fix that - put an f before the quote and drop variables straight into {}.
name = "Amina"
age = 24
balance = 15750.5
print(f"My name is {name} and I am {age} years old.")
print(f"Next year {name} will be {age + 1}")
print(f"Balance: Ksh {balance:,.2f}")
My name is Amina and I am 24 years old.
Next year Amina will be 25
Balance: Ksh 15,750.50
That last one - {balance:,.2f} - adds comma separators and rounds to two decimal places, right inside the string. The moment I showed that formatting trick, three people in the room said "wait, do it again."
The Moment Everything Clicked
I always end Session 1 by putting every single concept from the day into one program, live, in front of the class - a school grade calculator that asks for a name, a subject, and three test scores, then prints a full report.
print("===============================")
print(" KENYA SCHOOL GRADE CALCULATOR")
print("===============================")
print()
name = input("Student name: ")
subject = input("Subject: ")
print(f"Enter 3 test scores for {name}:")
score1 = int(input(" Test 1: "))
score2 = int(input(" Test 2: "))
score3 = int(input(" Test 3: "))
total = score1 + score2 + score3
average = total / 3
highest = max(score1, score2, score3)
lowest = min(score1, score2, score3)
print()
print("===============================")
print(f" REPORT: {name}")
print("===============================")
print(f"Subject: {subject}")
print(f"Scores: {score1}, {score2}, {score3}")
print(f"Total: {total} / 300")
print(f"Average: {round(average, 1)}")
print(f"Highest: {highest}")
print(f"Lowest: {lowest}")
===============================
KENYA SCHOOL GRADE CALCULATOR
===============================
Student name: Amina Wanjiku
Subject: Mathematics
Enter 3 test scores for Amina Wanjiku:
Test 1: 78
Test 2: 85
Test 3: 91
===============================
REPORT: Amina Wanjiku
===============================
Subject: Mathematics
Scores: 78, 85, 91
Total: 254 / 300
Average: 84.7
Highest: 91
Lowest: 78
Nobody in the room had written more than five lines of code an hour earlier. Watching that report print out, built entirely from things they'd just learned, is the reason I still enjoy teaching Session 1 even after doing it more than once.
Try It Yourself
Easy - Matatu fare calculator. Ask for the number of passengers and the fare per person, then print the total collected, the driver's 30% share, and the owner's 70% share. Test with 14 passengers at Ksh 80 each - you should get a total of Ksh 1,120.
Medium - M-Pesa send calculator. Ask for a sender name, a recipient name, and an amount. Hardcode a charge of Ksh 11, then print a summary showing sender, recipient, amount, charge, and total.
Challenge - Personal budget calculator. Ask for a name, a monthly salary, and four expenses (rent, food, transport, other). Calculate total expenses, savings, and savings as a percentage of salary - rounded to one decimal place. Bonus: print an encouraging message if savings are positive, and a warning if they're negative. Test with a salary of Ksh 50,000 and expenses of 18,000 / 8,000 / 4,000 / 5,000 - you should land on savings of Ksh 15,000, or 30% of salary.
What I Noticed Teaching This Round
- Starting with
print()instead of a definition of "programming" still works every time - people want to see something happen before they care why - The
"5" + "5"trap is unavoidable and that's fine - I'd rather they hit it in a safe example than three weeks from now debugging something real - f-strings landing before conditionals or loops means students write cleaner output from day one instead of learning commas first and unlearning them later
- This cohort asked more "why" questions than the last one - more of them are switching careers, not just adding a skill, and it shows in how carefully they read error messages
I'm a data trainer in Nairobi running a full data programme

Top comments (0)