WorksheetsGuided Notes: Functions that Return Values
Total questions: 16
Worksheet time: 8mins
A ________________ is a block of code designed to perform a specific task.
function
variable
loop
array
Some functions don’t just do something—they give something back. This is called a ________________ ________________.
return value or return function
void value or void function
static function
helper function
You use a ________________ ________________ to tell the function what value to send back when it's done.
return statement
print statement
input statement
break statement
In the function example above, a + b is the ________________ ________________.
return value
function name
parameter list
argument
When you call add(3, 4), the function will return ________________.
7
12
34
1
If you want to use the result of a return function, you can store it in a ________________:
variable
loop
operator
constant
The return statement is different from a print statement because it sends a value _______________ of the function instead of just showing it on the screen.
outside
inside
to the screen
to the variable
In the lesson, the "Practice Turn!" activity helped you practice using return values by writing and calling functions that return _______________.
values
loops
errors
variables
Sometimes, one function can be called _______________ another function. This is useful for breaking down a big task into smaller steps.
inside
before
after
outside
Using return values helps keep your code clean, organized, and easy to _______________.
maintain
ignore
break
complicate
A function should return a value instead of just printing it because:
it allows the value to be used elsewhere in the program.
it makes the output more colorful.
it increases the speed of the function.
it prevents the function from being called again.
If a function is supposed to return something but doesn’t include a return statement, what could happen?
The function returns undefined or nothing.
The function will throw a syntax error.
The function will automatically return zero.
The function will return the last variable used.
Calling one function inside another helps you solve more complex problems by:
Breaking down tasks into smaller, manageable parts.
Making the code run slower.
Increasing the number of errors in the program.
Limiting the use of variables.
Returning a value from a function is useful because:
It allows the function to provide a result that can be used elsewhere in the program.
It makes the function run faster.
It prevents the function from being called again.
It automatically saves the program.
If a function does not return a value when one is expected, what happens?
An error or undefined value may occur.
The function will always return 0.
The program will automatically assign a random value.
The function will return the value of the last variable used.
Breaking a problem into smaller pieces helps in programming by:
making the problem easier to solve and manage
increasing the complexity of the problem
making debugging more difficult
reducing code readability
