Skip to main content

Functions: parameters, return values, and scope

programmingHigh school (ages 14–18)5 skills
Approved

PDF fits print binders and resource directories; HTML and embeds fit course platforms and LMS pages. LearnWorlds — Host or sell a full course around your module · Homeschool Resource Co. — Find printable supplements and curriculum packs

Some links may be affiliate partnerships — we may earn a commission at no extra cost to you.

Total Time

60m

Skills

5

Pedagogical Notes

Scope is the most challenging concept - use visual diagrams showing variable 'boxes' inside vs outside functions. Practice with concrete examples like name conflicts. Return values should be practiced with immediate use of results to reinforce the concept.

Foundational Knowledge (Assumed)

Basic programming constructs — Understanding of variables, loops, and conditionals
Code organization concepts — Understanding that code can be broken into reusable parts

Prerequisite Skills

Function definition syntax
12mDiff 1

Write basic function definitions with def keyword and proper indentation

Function calling
15mDiff 1

Call functions by name and understand execution flow

Variable assignment
10mDiff 1

Assign values to variables and understand variable names

Core Skills

Single parameter functions
15mDiff 1

Define and call functions that accept one parameter

Creating greeting functions with namesMath functions like square(x)
Multiple parameter functions
12mDiff 2

Define and call functions with multiple parameters in correct order

Calculator functions add(a,b)Drawing functions rectangle(width, height)
Return values
18mDiff 2

Use return statement to send values back from functions

Math calculations that give resultsFunctions that process and return data
Using return values
15mDiff 2

Capture and use values returned from function calls

Storing calculation resultsChaining function calls together
Local variable scope
20mDiff 3

Understand that variables inside functions are separate from outside variables

Avoiding variable name conflictsUnderstanding function independence

Extension Skills

Default parameter values
18mDiff 3

Define functions with optional parameters that have default values

Global vs local scope conflicts
22mDiff 4

Understand and resolve situations where local and global variables have same names

Skill Dependencies

Single parameter functions←Function calling, Variable assignment
Multiple parameter functions←Single parameter functions
Return values←Single parameter functions
Using return values←Return values
Local variable scope←Multiple parameter functions, Return values
Default parameter values←Multiple parameter functions
Global vs local scope conflicts←Local variable scope
Function definition syntax←(no prerequisites)
Function calling←Function definition syntax
Variable assignment←(no prerequisites)

Rate this module

Not yet rated