wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Returning Values from Functions and Methods Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.
What does the statement 'd = d + 3' represent in programming?
a)
Replacing the variable d with the number 3
b)
Increasing the current value of d by 3
c)
Subtracting 3 from d
d)
Creating a new variable named d
2.
In the context of the presentation, what is a variable most similar to?
a)
A permanent storage device
b)
A container that can hold different values
c)
A mathematical equation
d)
A computer hardware component
3.
What is the term for gradually reducing a variable's value by 1?
a)
Negative increment
b)
Variable subtraction
c)
Value reduction
d)
Decremental value
4.
If 'd = 8' and then 'd = d - 3' is executed, what will be the final value of d?
a)
2
b)
11
c)
3
d)
5
5.
Which statement best describes how variables can change in programming?
a)
Variables cannot be modified after initial assignment
b)
Variables can be updated during program execution
c)
Variables must always start at zero
d)
Variables can only hold one value forever
6.
What metaphor was used in the presentation to explain changing variable values?
a)
A mathematical equation
b)
A computer processing data
c)
A cup of water changing color
d)
A computer circuit
7.
What happens when you use the statement 'd = d + 10'?
a)
The current value of d is increased by 10
b)
The variable d is replaced with 10
c)
The variable d is deleted
d)
A new variable is created
8.
What is the primary purpose of a return value in a function?
a)
To create a new variable
b)
To define a new method
c)
To provide a result after completing a task
d)
To stop the program execution
9.
In the syntax turtle.step(turtle.distanceTo(bush)), how are the values being passed?
a)
By creating a new object
b)
Using a separate variable
c)
Directly from one function to another
d)
Through manual input
10.
What is the benefit of storing a function's return value in a variable?
a)
It reduces code readability
b)
It allows you to reuse the value multiple times
c)
It prevents the function from working
d)
It makes the code longer
11.
Which of the following best describes the process of passing a return value?
a)
A technique to slow down program execution
b)
A method to create infinite loops
c)
A function that never completes
d)
A way to transfer information between different parts of a program
12.
What does the distanceTo() method typically return?
a)
A string
b)
A numerical distance
c)
A boolean value
d)
An object
13.
In the lesson's example with a monkey and a banana, what was the first step in the algorithm?
a)
Calculate the distance
b)
Turn the monkey to the banana
c)
Pick up the banana
d)
Stop the program
14.
What is the key difference between passing values using a variable versus directly?
a)
Variable method provides more flexibility in storing and manipulating values
b)
Direct method is always faster
c)
There is no difference
d)
Variable method allows for more complex calculations
15.
Which coding concept was the primary focus of this lesson?
a)
Returning value from functions and methods
b)
Object-oriented programming
c)
Loop creation
d)
Data encryption