>_BeginnerCoder
Donate

Lesson 7 — Functions

Reusable blocks

A function packages code under a name so you can run it again and again by "calling" it. It can take inputs (parameters) and hand back a result with return.

Why it matters: functions keep code short, organised and easy to fix — write the logic once, reuse it everywhere.

Watch out: return sends a value back to the caller; print() only shows it. They are not the same.

Task

Write add(a, b) that returns a + b, then print add(2, 3).

← Back
Next →

Enjoying this lesson? Share it 👇

Keep going with Python Foundations

Ready for more? These paid resources pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. We only recommend tools we believe are genuinely useful.