Skip to main content\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 16.11 Review - Functions
Practice reading, tracing, testing, and writing simple functions.
Subsection 16.11.1 Part A: Recognize
Checkpoint 16.11.1.
Study the function below and label the function name, parameter, return statement, function call, and argument.
def double(value):
return value * 2
result = double(5)
Subsection 16.11.2 Part B: Trace
Checkpoint 16.11.2.
def add_one(num):
return num + 1
What value is returned by
add_one(4),
add_one(10), and
add_one(-1)?
Subsection 16.11.3 Part C: Match
Checkpoint 16.11.3.
Match each function to its purpose.
def a_function(x):
return x ** x
def a_function(x):
return x * x
def a_function(x):
return x ** 2
- returns the square of a number
def a_function(name):
return "Hello, " + name
- returns a greeting string
def a_function(num):
return num > 0
def a_function(num):
return num >= 1
- checks whether a number is positive
Subsection 16.11.4 Part D: Fix
Checkpoint 16.11.4.
Correct the errors in the function below.
Subsection 16.11.5 Part E: Create
Checkpoint 16.11.5.
Write a function named
subtract that takes two parameters and returns the difference of the first minus the second. Then write three test calls.
Subsection 16.11.6 Think About ...
Checkpoint 16.11.6.
What is the difference between
print() and
return inside a function?
You have attempted
of
activities on this page.