← Python Coding Track

Module 01FoundationWeeks 1–2

Python Basics

01

Learning outcomes

  • Write a first script
  • Understand variables and data types
02

Core concepts

VariablesNaming conventionsData types (string, integer, float, boolean)Comments
03

Lessons

Module goal

Learner writes their first real script and understands what variables and data types actually are — not just how to spell them, but why they exist and how Python treats them.

Lesson 1 of 4 · lecture

What is a variable?

Step 1 of 3

A variable is a named container that stores a piece of information so you can use it later. Think of a labelled box: write “age” on a box, put 25 inside, and any time you say age, Python looks in that box.

age = 25
name = "Kenneth"

Common confusion

The = sign does not mean “equals” as in maths — it means “assign this value to this name”. Read age = 25 as “age is now set to 25”.

Why variables matter: without them every program would hardcode values everywhere, and changing one thing would mean hunting through the entire script. Variables make code flexible, reusable and readable.

04

Guided labs

Build your personal info script

  1. 1.Create a new file called basics.py
  2. 2.Create four variables: name (string), age (integer), city (string), favourite language (string)
  3. 3.Add a comment above each variable explaining what it stores
  4. 4.Use print() to display a full sentence combining all four
name = "Kenneth"
age = 30
city = "Accra"
language = "Python"

# Print a formatted introduction using all variables
print("My name is " + name + ", I am " + str(age) + " years old, I live in " + city + ", and I'm learning " + language + ".")

# Cleaner, modern alternative — an f-string
print(f"My name is {name}, I am {age} years old, I live in {city}, and I'm learning {language}.")

Teaching point

f-strings are preferred in professional Python: cleaner, more readable, and they handle type conversion automatically so you never need str() inside them.

Success criteria

Running the script prints a complete, correctly formatted sentence with no errors.

05

Knowledge Check

Question 1 of 6

What does the = sign do in Python when creating a variable?

06

What you read

  • What a variable is (a container for information)
  • Naming rules (no spaces, start with a letter, avoid reserved words)
  • Why data types matter (numbers vs. text behave differently)
07

What you understand

Key takeaways

  • Variables store and reuse information
  • Different data types behave differently in operations
  • Comments make code readable for future reference
08

Hands-on lab

Lab tasks

  1. 1.Create variables for name, age, favorite language
  2. 2.Print a formatted sentence using them
09

Knowledge check

  • Identify data types
  • Spot naming errors
  • Explain a variable's purpose

Write your answers in your own notes before moving on — explaining a concept in your own words is the fastest way to find the gaps.

10

Mark progress