Hi, Guest! 👋

Saturday, 14 November 2026 · Guest session
N
Back to blog
GENERAL

5 Python patterns every NIA student should know

AWAmina Wanjiru
Nov 14, 2026 · 5:45 AM
217 views · 14 likes

These patterns cover 80% of the Python exercises we do in class.

1. f-strings for output

python
name = "Amina"
score = 87
print(f"{name} scored {score}%")

2. Dictionaries instead of long if-else

python
charges = {"ICT": 1500, "Business": 1200, "Electrical": 1800}
print(charges.get("ICT", 0))

3. List comprehensions

python
passing = [s for s in scores if s >= 50]

4. range with steps

python
for i in range(2, 22, 2):
    print(i)  # even numbers

5. zip for parallel lists

python
for name, score in zip(names, scores):
    print(name, score)
pythontips

1 comments
FN Faith Njeri · 15h agoThe dictionary pattern made my assignment so much shorter. Thanks!
Sign in to join the discussion.
About the author
AW
Amina Wanjiru
NIA College student
View portfolio
Write your own

Share a tutorial or project story. Code blocks get syntax highlighting automatically.

New post
Today's challenge Write a blog post Community chat Developers Directory Resource centre Add a project