10

Lesson 10 of 20 · Functions with Parameters

Functions with Parameters — Part 18

Pass information into a function. This is part 18 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 with Parameters — Part 18

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

Full screen — no distractions

🖨️

Checkout complete lesson on Functions with Parameters for 5th Grade

Get the full Functions with Parameters 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 with Parameters — Part 18 — Functions with Parameters | 5th Grade Coding | LittleActivity