Python · Stage 6 – Reusable Code · Lesson 33 of 50

What Is a Function?

Understand reusable named instructions before learning function syntax.

Copying the same instructions into several places makes mistakes harder to fix. A function gives that work one home and a meaningful name.

print("Welcome")
Line-by-line explanation
  1. print is a function Python already provides.
  2. The function name describes its job.
  3. Round brackets contain the information given to it.

Tiny Practice

Call the built-in print function with a message.

Starter template

CHANGE_ME("Hello")
Line-by-line explanation
  1. The brackets and message are ready.
  2. Only the function name is missing.
Hint
  1. Use a built-in function from earlier lessons.
  2. Its name begins with p.
  3. Do not quote the function name.
Show Solution
print("Hello")
Line-by-line explanation
  1. print names the function.
  2. The brackets call it.
  3. Hello is displayed.