14

Lesson 14 of 20 · Functions

Functions — Part 3

Parameters and return values. This is part 3 of 20.

What you'll learn

You will learn how to create reusable code with functions — define once, call many times.

Steps

  1. 1'def say_hi():' creates a function — think of it as teaching the computer a new trick called 'say_hi'.
  2. 2The indented line print('Hi!') is what the trick does. But it doesn't run yet — we've only defined it, not called it.
  3. 3say_hi() on lines 3 and 4 CALLS the function — it tells the computer: 'do that trick now!' It runs twice, so 'Hi!' appears twice.
  4. 4Functions are reusable! Define a function once, then call it as many times as you need. This saves you from repeating code.

Key Terms

Function
A named block of code you can run whenever you want by writing its name and ().
Define
To create a function (with def). You define it once.
Call
To run a function by writing its name and (). Each call runs the function's code.
Python 3
Output
Loading Python... This may take a few seconds.

Your code runs only in your browser. No code is sent to any server. Stay safe and have fun learning!

Ready?

Functions — Part 3

You will learn how to create reusable code with functions — define once, call many times.

Full screen — no distractions

🖨️

Checkout complete lesson on Functions for 7th Grade

Get the full Functions track as a printable PDF — all lessons, worksheets, and answer keys.

View in Shop

Your Cart (0)

Your cart is empty

Browse our shop to find activities your kids will love

Functions — Part 3 — Functions | 7th Grade Coding | LittleActivity