# Python — The Language of Power
my_bag = ['books', 'phone', 'money']
student = {'name': 'Elemson', 'age': 18}
class Human:
def __init__(self, name):
[Link] = name
PYTHON FOR BEGINNERS
Lists · Dictionaries · OOP
Written in baby language — zero confusion guaranteed
By Elemson • Python Study Series • 2026
# Python — The Language of Power
my_bag = ['books', 'phone', 'money']
student = {'name': 'Elemson', 'age': 18}
class Human:
def __init__(self, name):
[Link] = name
PYTHON FOR BEGINNERS
Lists · Dictionaries · OOP
Written in baby language — zero confusion guaranteed
By Elemson • Python Study Series • 2026
Python for Beginners Page 3
TABLE OF CONTENTS
PART 1 — LISTS
• What is a list?
• Creating & accessing lists
• Changing, adding & removing items
• Looping through lists
• Useful list methods
• List slicing
• Nested lists
PART 2 — DICTIONARIES
• What is a dictionary?
• Creating & accessing dictionaries
• Adding, updating & deleting
• Looping through dictionaries
• Useful dictionary methods
• Nested dictionaries
PART 3 — OOP IN A NUTSHELL
• What is OOP?
• Classes and objects
• The __init__ method
• Instance methods
• Inheritance — child classes
• Encapsulation
• Putting it all together — real project
Python for Beginners Page 4
PART 1
LISTS
1.
1 What is a List?
A list is one of the most used things in Python. It is basically a container that holds multiple
items in one variable. Instead of creating 5 different variables to store 5 names, you just put
them all in one list.
■ Think of it like this: You know how a shopping bag holds many items — bread, eggs,
milk, sugar? A Python list is exactly that bag. One bag, many things inside.
# Without a list — this is annoying:
fruit1 = "mango"
fruit2 = "banana"
fruit3 = "orange"
# With a list — clean and simple:
fruits = ["mango", "banana", "orange"]
print(fruits)
["mango", "banana", "orange"]
A list is written with square brackets [ ] and items are separated by commas. A list can hold
anything: strings, numbers, even other lists.
# List of numbers
marks = [85, 92, 78, 95, 60]
# Mixed list (strings + numbers)
student = ["Elemson", 18, "Zambia", True]
# Even an empty list
empty = []
1.
2 Accessing Items in a List
Python for Beginners Page 5
Each item in a list has an index — a position number. Python starts counting from 0, not 1. This
trips up beginners, so burn it into your brain.
■ Think of it like this: Imagine seats in a minibus. The FIRST seat is seat number 0 (in
Python world). Second seat is 1, third is 2, and so on.
fruits = ["mango", "banana", "orange", "guava", "lemon"]
# Index: 0 1 2 3 4
print(fruits[0]) # First item
print(fruits[2]) # Third item
print(fruits[-1]) # Last item (negative index!)
print(fruits[-2]) # Second to last
mango
orange
lemon
guava
■ Note: Negative indexing: -1 always gives you the LAST item, -2 the second to last, etc. Super
useful when you don't know the length.
■ Watch out: Trying to access an index that doesn't exist will crash your code with an IndexError. If
your list has 5 items, valid indices are 0 to 4.
1.
3 Changing, Adding & Removing Items
Changing an item
fruits = ["mango", "banana", "orange"]
# Change banana to watermelon
fruits[1] = "watermelon"
print(fruits)
["mango", "watermelon", "orange"]
Adding items
fruits = ["mango", "banana"]
# append() — adds to the END
Python for Beginners Page 6
[Link]("orange")
print(fruits)
# insert() — adds at a specific position
[Link](1, "guava") # insert at index 1
print(fruits)
["mango", "banana", "orange"]
["mango", "guava", "banana", "orange"]
Removing items
fruits = ["mango", "banana", "orange", "guava"]
# remove() — removes by VALUE
[Link]("banana")
print(fruits)
# pop() — removes by INDEX (default: last item)
[Link](0) # removes 'mango'
print(fruits)
# pop() with no argument removes last item
[Link]()
print(fruits)
["mango", "orange", "guava"]
["orange", "guava"]
["orange"]
1.
4 Looping Through a List
A loop lets you go through every item in a list one by one and do something with it. This is where
lists become incredibly powerful.
names = ["Elemson", "Sarah", "John", "Mercy"]
# Simple for loop
for name in names:
print("Hello,", name)
Python for Beginners Page 7
Hello, Elemson
Hello, Sarah
Hello, John
Hello, Mercy
You can also loop with the index using enumerate() — it gives you both the position AND the
value.
fruits = ["mango", "banana", "orange"]
for index, fruit in enumerate(fruits):
print(f"Position {index}: {fruit}")
Position 0: mango
Position 1: banana
Position 2: orange
■ Tip: The f-string f"Position {index}: {fruit}" is a clean way to put variables inside a string. The curly
braces {} are replaced with the actual values.
1.
5 Useful List Methods
Method What it does Example
append(x) Add x to end [Link]("hi")
insert(i, x) Add x at index i [Link](0, "hi")
remove(x) Remove first x found [Link]("hi")
pop(i) Remove & return item at i [Link](2)
sort() Sort in ascending order [Link]()
reverse() Reverse the list [Link]()
len(lst) Get number of items len(lst)
count(x) Count occurrences of x [Link]("hi")
index(x) Find index of x [Link]("hi")
clear() Remove all items [Link]()
copy() Make a copy of the list new = [Link]()
numbers = [5, 2, 9, 1, 7, 3]
Python for Beginners Page 8
[Link]()
print(numbers)
[Link]()
print(numbers)
print('Length:', len(numbers))
print('Count of 9:', [Link](9))
[1, 2, 3, 5, 7, 9]
[9, 7, 5, 3, 2, 1]
Length: 6
Count of 9: 1
1.
6 List Slicing — Getting a Chunk
Slicing lets you grab a portion of a list. Syntax: list[start:end]. Note: the end index is NOT
included.
■ Think of it like this: Imagine a loaf of bread. Slicing [1:4] means: start from slice 1, stop
BEFORE slice 4. You get slices 1, 2, and 3.
letters = ["a", "b", "c", "d", "e", "f", "g"]
# index: 0 1 2 3 4 5 6
print(letters[1:4]) # from index 1 up to (not including) 4
print(letters[:3]) # from start up to index 3
print(letters[4:]) # from index 4 to end
print(letters[::2]) # every 2nd item
print(letters[::-1]) # REVERSE the list
['b', 'c', 'd']
['a', 'b', 'c']
['e', 'f', 'g']
['a', 'c', 'e', 'g']
['g', 'f', 'e', 'd', 'c', 'b', 'a']
Python for Beginners Page 9
1.
7 Nested Lists — Lists Inside Lists
A list can contain other lists. This is called a nested list. It's how you represent a table or grid in
Python.
# A 3x3 grid (like a tic-tac-toe board)
grid = [
["X", "O", "X"],
["O", "X", "O"],
["X", "O", "X"]
# Access row 0, column 1:
print(grid[0][1]) # 'O'
# Print the whole grid
for row in grid:
print(row)
['X', 'O', 'X']
['O', 'X', 'O']
['X', 'O', 'X']
■ CHALLENGE: Lists
Create a list of 5 of your favourite songs. Print the first and last song. Add a new song at
index 2. Remove the 4th song. Print the final list.
Python for Beginners Page 10
PART 2
DICTIONARIES
2.
1 What is a Dictionary?
A dictionary stores data in key–value pairs. Instead of using a number index (like lists), you
access items using a key — which is usually a word.
■ Think of it like this: Think of an actual dictionary book. You look up a WORD (the key)
and it gives you the DEFINITION (the value). Python dictionaries work exactly the same
way. You look up a key and get back its value.
# A student dictionary
student = {
"name": "Elemson",
"age": 18,
"school": "Chilenje South High",
"grade": "Grade 12"
print(student["name"])
print(student["age"])
Elemson
18
■ Note: Dictionaries use curly braces { }. Each item is written as key: value. Keys are usually
strings. Values can be ANYTHING.
2.
2 Creating & Accessing Dictionaries
# Method 1: direct creation
car = {"brand": "Toyota", "model": "Corolla", "year": 2020}
# Method 2: dict() constructor
person = dict(name="Sarah", age=22, city="Lusaka")
Python for Beginners Page 11
# Accessing values
print(car["brand"]) # Method 1: square brackets
print([Link]("model")) # Method 2: .get() — SAFER
print([Link]("colour")) # Returns None (not a crash!)
print([Link]("colour", "Unknown")) # Default value
Toyota
Corolla
None
Unknown
■ Tip: Always prefer .get() over square brackets when you're not 100% sure the key exists. Square
brackets crash your program with a KeyError if the key is missing.
2.
3 Adding, Updating & Deleting
student = {"name": "Elemson", "age": 18}
# ADD a new key-value pair
student["university"] = "CBU"
print(student)
# UPDATE an existing value
student["age"] = 19
print(student)
# DELETE a key
del student["age"]
print(student)
# pop() — removes and returns the value
name = [Link]("name")
print("Removed:", name)
print(student)
{'name': 'Elemson', 'age': 18, 'university': 'CBU'}
{'name': 'Elemson', 'age': 19, 'university': 'CBU'}
{'name': 'Elemson', 'university': 'CBU'}
Python for Beginners Page 12
Removed: Elemson
{'university': 'CBU'}
2.
4 Looping Through a Dictionary
profile = {
"name": "Elemson",
"age": 18,
"city": "Lusaka",
"hobby": "Football"
# Loop through KEYS only
for key in profile:
print(key)
# Loop through VALUES only
for value in [Link]():
print(value)
# Loop through BOTH keys and values
for key, value in [Link]():
print(f"{key} --> {value}")
name / age / city / hobby
Elemson / 18 / Lusaka / Football
name --> Elemson
age --> 18
city --> Lusaka
hobby --> Football
2.
5 Useful Dictionary Methods
Method What it does
.get(key, default) Safely get a value, return default if not found
Python for Beginners Page 13
.keys() Returns all keys
.values() Returns all values
.items() Returns all key-value pairs (as tuples)
.update({...}) Merge another dictionary in
.pop(key) Remove & return a value by key
.clear() Remove everything
.copy() Make a copy of the dictionary
key in dict Check if a key exists (True/False)
phone = {"brand": "Samsung", "ram": "8GB", "price": 2500}
# Check if key exists
"brand" in phone # True
"colour" in phone # False
# Merge two dicts
extra = {"colour": "Black", "storage": "128GB"}
[Link](extra)
print(phone)
{'brand': 'Samsung', 'ram': '8GB', 'price': 2500, 'colour':
'Black', 'storage': '128GB'}
2.
6 Nested Dictionaries — Dict Inside Dict
Just like nested lists, you can put a dictionary inside another dictionary. This is perfect for storing
structured data about multiple items.
# A school with multiple students
school = {
"student1": {"name": "Elemson", "age": 18, "grade": "A"},
"student2": {"name": "Sarah", "age": 17, "grade": "B"},
"student3": {"name": "John", "age": 19, "grade": "A"},
# Access Elemson's grade
Python for Beginners Page 14
print(school["student1"]["grade"])
# Loop through all students
for student_id, info in [Link]():
print(f"{info['name']} got grade {info['grade']}")
Elemson got grade A
Sarah got grade B
John got grade A
■ CHALLENGE: Dictionaries
Create a dictionary for yourself with keys: name, age, school, favourite_subject, and
dream_job. Print each key and value using a loop. Then add 2 more keys and delete one
existing key.
Python for Beginners Page 15
PART 3
OOP — OBJECT ORIENTED
PROGRAMMING
3.
1 What is OOP? The Big Idea
OOP is a way of organising your code by grouping related data and actions together into
something called a class. Instead of writing random functions and variables everywhere, you
package everything neatly.
■ Think of it like this: Think about a smartphone. Every smartphone has: attributes
(brand, colour, battery level, storage) and actions (call, text, take photo, charge). In OOP,
the SMARTPHONE is a CLASS. Your specific Samsung Galaxy is an OBJECT — a real
instance of that class.
Concept Real World Python
Class Blueprint/Template The design of a house
Object The actual thing A specific house built from that design
Attribute Property/data Colour, size, number of rooms
Method Action/behaviour Open door, switch on lights
3.
2 Creating a Class and an Object
You create a class using the class keyword. By convention, class names start with a Capital
Letter.
# Define the class (the blueprint)
class Dog:
pass # 'pass' means empty for now
# Create objects (actual dogs) from the blueprint
dog1 = Dog()
dog2 = Dog()
print(dog1) # Shows it's a Dog object
Python for Beginners Page 16
print(dog2) # Different object, same class
<__main__.Dog object at 0x...>
<__main__.Dog object at 0x...>
■ Note: dog1 and dog2 are two different objects even though they come from the same class, just
like two different dogs — both are dogs, but they are separate individuals.
3.
3 The __init__ Method — Giving Objects Data
Every class should have an __init__ method (short for 'initialise'). This method runs
automatically when you create a new object. It's where you set up the object's starting data.
■ Think of it like this: When a baby is born (object created), it immediately gets a name, a
birth date, a nationality. That's what __init__ does — it gives the object its starting values
the moment it's created.
class Student:
def __init__(self, name, age, school):
[Link] = name
[Link] = age
[Link] = school
# Create students by passing values
student1 = Student("Elemson", 18, "Chilenje South")
student2 = Student("Sarah", 17, "Kabulonga Girls")
# Access attributes with dot notation
print([Link])
print([Link])
print([Link])
Elemson
18
Kabulonga Girls
self is a reference to the object itself. When you write [Link] = name, you're saying: 'Store
this name value ON THIS specific object'. Every method in a class must have self as its first
parameter.
Python for Beginners Page 17
■ Watch out: Never forget 'self' as the first parameter in your methods. Python will throw a confusing
error if you do.
3.
4 Instance Methods — Giving Objects Actions
Methods are functions that belong to a class. They define what an object can do. They always
take self as the first parameter.
class Student:
def __init__(self, name, age, school):
[Link] = name
[Link] = age
[Link] = school
[Link] = [] # start with empty marks
def introduce(self):
print(f"Hi! I am {[Link]}, {[Link]} years old.")
print(f"I study at {[Link]}.")
def add_mark(self, subject, mark):
[Link]({subject: mark})
print(f"Added {mark} for {subject}")
def average_mark(self):
if len([Link]) == 0:
return "No marks yet"
total = sum(m for d in [Link] for m in [Link]())
return total / len([Link])
# Create a student
elemson = Student("Elemson", 18, "Chilenje South")
# Call methods
[Link]()
elemson.add_mark("Maths", 92)
elemson.add_mark("Science", 87)
elemson.add_mark("English", 78)
print(f"Average: {elemson.average_mark():.1f}")
Python for Beginners Page 18
Hi! I am Elemson, 18 years old.
I study at Chilenje South.
Added 92 for Maths
Added 87 for Science
Added 78 for English
Average: 85.7
3.
5 Inheritance — Child Classes
Inheritance lets a new class inherit all the attributes and methods of an existing class, and then
add or change things on top of it.
■ Think of it like this: You inherit certain traits from your parents — skin tone, height,
maybe their smile. But you also have your own unique personality and skills on top of what
you inherited. Child classes work exactly like this.
# PARENT class
class Person:
def __init__(self, name, age):
[Link] = name
[Link] = age
def greet(self):
print(f"Hello, I am {[Link]}.")
# CHILD class — inherits from Person
class Student(Person): # <-- Person in brackets = inherit!
def __init__(self, name, age, school):
super().__init__(name, age) # call parent's __init__
[Link] = school
def study(self):
print(f"{[Link]} is studying hard at {[Link]}!")
# Another child class
class Teacher(Person):
def __init__(self, name, age, subject):
Python for Beginners Page 19
super().__init__(name, age)
[Link] = subject
def teach(self):
print(f"{[Link]} teaches {[Link]}.")
# Using them
student = Student("Elemson", 18, "CBU")
teacher = Teacher("Mr. Banda", 35, "Mathematics")
[Link]() # inherited from Person
[Link]() # Student's own method
[Link]() # inherited from Person
[Link]() # Teacher's own method
Hello, I am Elemson.
Elemson is studying hard at CBU!
Hello, I am Mr. Banda.
Mr. Banda teaches Mathematics.
■ Note: super() calls the parent class. When you write super().__init__(), you're saying: 'Run the
parent's __init__ first, then I'll add my own stuff'.
3.
6 Encapsulation — Protecting Your Data
Encapsulation means hiding certain data from the outside world. You control what people can
see and change about your object.
■ Think of it like this: Your ATM card has a PIN. The bank protects (encapsulates) your
account details. You can deposit or withdraw through specific methods, but you can't just
directly change your balance by reaching into the system.
class BankAccount:
def __init__(self, owner, balance):
[Link] = owner
self.__balance = balance # __ = private! hidden from outside
def deposit(self, amount):
if amount > 0:
Python for Beginners Page 20
self.__balance += amount
print(f"Deposited K{amount}. New balance: K{self.__balance}")
def withdraw(self, amount):
if amount > self.__balance:
print("Insufficient funds!")
else:
self.__balance -= amount
print(f"Withdrew K{amount}. Remaining: K{self.__balance}")
def get_balance(self):
return self.__balance
account = BankAccount("Elemson", 5000)
[Link](1500)
[Link](200)
[Link](10000)
print("Balance:", account.get_balance())
# This would FAIL — you can't access private attributes directly
# print(account.__balance) # AttributeError!
Deposited K1500. New balance: K6500
Withdrew K200. Remaining: K6300
Insufficient funds!
Balance: 6300
■ Tip: Variables with double underscore __ prefix are 'private' — they're hidden from direct access
outside the class. This protects your data.
Python for Beginners Page 21
3.
7 Putting It All Together — A Real Mini Project
Let's build a simple Phone Book system that uses everything — classes, objects, lists, and
dictionaries all working together.
class Contact:
def __init__(self, name, phone, email=''):
[Link] = name
[Link] = phone
[Link] = email
def display(self):
print(f" Name : {[Link]}")
print(f" Phone: {[Link]}")
if [Link]:
print(f" Email: {[Link]}")
print("-" * 30)
class PhoneBook:
def __init__(self):
[Link] = [] # list of Contact objects
def add_contact(self, name, phone, email=''):
new_contact = Contact(name, phone, email)
[Link](new_contact)
print(f"Contact {name} added!")
def search(self, name):
for contact in [Link]:
if [Link]() == [Link]():
print("Found:")
[Link]()
return
print(f"No contact named {name} found.")
def show_all(self):
print("=== ALL CONTACTS ===")
Python for Beginners Page 22
for contact in [Link]:
[Link]()
def delete(self, name):
for i, contact in enumerate([Link]):
if [Link]() == [Link]():
[Link](i)
print(f"{name} deleted.")
return
print("Contact not found.")
# USE IT
book = PhoneBook()
book.add_contact("Elemson", "0978123456", "elemson@[Link]")
book.add_contact("Sarah", "0955987654")
book.add_contact("John", "0967111222", "john@[Link]")
book.show_all()
[Link]("sarah")
[Link]("Sarah")
book.show_all()
Contact Elemson added!
Contact Sarah added!
Contact John added!
=== ALL CONTACTS ===
Name : Elemson | Phone: 0978123456 | Email: elemson@[Link]
Name : Sarah | Phone: 0955987654
Name : John | Phone: 0967111222 | Email: john@[Link]
Found:
Name : Sarah | Phone: 0955987654
Sarah deleted.
=== ALL CONTACTS ===
Name : Elemson | Name : John
Python for Beginners Page 23
■ CHALLENGE: Final Boss Challenge — OOP
Build a Library system. Create a Book class with attributes: title, author, pages, available
(True/False). Create a Library class with a list of books. Add methods: add_book(),
borrow_book(title) (sets available=False), return_book(title), and show_available(). Test
it with at least 3 books.
Python for Beginners Page 24
QUICK REFERENCE CHEAT SHEET
LISTS DICTIONARIES OOP
Create: lst = [1,2,3] Create: d = {k: v} Class: class MyClass:
Access: lst[0] Access: d[key] Init: def __init__(self):
Add end: [Link](x) Safe: [Link](key) Attr: [Link] = x
Add mid: [Link](i,x) Add/Set: d[key] = v Method: def do(self):
Remove: [Link](x) Delete: del d[key] Object: obj = MyClass()
Pop: [Link](i) Keys: [Link]() Access: [Link]
Length: len(lst) Values: [Link]() Call: [Link]()
Sort: [Link]() Pairs: [Link]() Inherit: class B(A):
Slice: lst[1:4] Update: [Link]({}) Parent: super().__init__()
Loop: for x in lst: Check: key in d Private: self.__secret
You now know Lists, Dictionaries, and OOP. These are not just Python concepts — they are
the foundation of every serious program ever written. Practice daily. Build small projects.
You are already ahead of most beginners. ■