No student devices needed. Know more
45 questions
Cutting a big program up into smaller subprograms (functions, procedures, etc)
modularity
procedural abstraction
In computer programming, this allows you to use a function knowing WHAT it does but not necessarily HOW it does it.
modularity
procedural abstraction
Directions for how a collection of functions behave and can be used
Library
API
A group of functions (procedures) that may be used in creating new programs
library
API
the orange x is a parameter
the orange x is an argument
the "7" is a parameter
the "7" is an argument
the variable "y" on line 2 is a parameter
the variable "y" on line 2 is an argument
the variable "year" in function getYear(year)
is a parameter
the variable "year" in function getYear(year)
is an argument
a variable used as a place holder for a value passed to a function
parameter
argument
a value passed to a function
parameter
argument
<MISSING CODE> should be:
x % 2 == 0
<MISSING CODE> should be:
x % 2 == 1
<MISSING CODE> should be:
x % 1 == 0
<MISSING CODE> should be:
x % 1 == 2
<MISSING CODE> should be:
x % 1 == 1
0
5
4
0.2
3
3.75
0.267
0
1
2.14
2
0.41
In the above picture, this would be an example of a:
Local Variable
Nested Variable
Global Variable
Variable Scope
In the above picture, this would be an example of a:
Local Variable
Nested Variable
Global Variable
Variable Scope
A variable whose scope is "global" to the program, it can be used and updated by any part of the code. Its global scope is typically derived from the variable being declared (created) outside of any function, object, or method.
Global Variable
Local Variable
Wide Variable
Limited Variable
A variable with local scope is one that can only be seen, used and updated by code within the same scope. Typically this means the variable was declared (created) inside a function -- includes function parameter variables.
Short Variable
Small Variable
Global Variable
Local Variable
A function must always have parameters in order for it to work.
True
False
A function must have a return value in order for it work properly.
True
False
A function can have a parameter(s) but not necessarily have a return value.
True
False
A function can have a return value but not necessarily have any parameters.
True
False
Which of the following is FALSE regarding functions?
(a) Functions with parameters and return values help us simplify our code
(b) A function can have parameters, but no return values
(c) A function can return multiple values at one time
A, B, C are all false
Look at this code. Which of the following will be shown in the console log when this program is ran?
This line always runs
This line always runs
But this one never does
But this one never does
Nothing will run in the console log
A function is also known as a procedure
True
False
An argument can include:
(a) a number
(b) a string
Both A and B
Neither A or B
Which of the following is FALSE regarding return values?
(A) It stops the flow of the function
(B) If a return is inside of a conditional, if that condition is met the function ends there.
(C) It returns a value to the place where the function was called.
None of these (A, B, C are all True)
A function return value can never be stored inside a variable.
True
False
In the example above, we say that lives is a local variable.
True
False
We say that function parameters are a form of a local variable because (choose all that apply):
they get created and initialized when a function is called
they get used while the function runs
they get destroyed when the function completes
they can be used both inside and outside of a given function
One of the disadvantages of writing functions that use parameters and return values is that it repeats code multiple times making your program disorganized and not very clean.
True
False
Once functions are written that take parameters and return values, it's easier to reuse that code in other places of your program.
True
False
Looking at this image, which of the following would be considered a parameter for the function totalCost?
total
check
cost
There are no parameters for this function
The function move(id, direction) could be used to move an element in any direction, rather than writing separate functions for each direction. This is considered an example of:
Modularity
Procedural Abstraction
Library
API
What will print to the console after running this code segment?
10
60
54
56
What is printed to the console log?
console.log (12 % 3);
4
3
0
2
A library should have all of the following documentation EXCEPT:
(A) how each function works
(B) a complete list of the arguments
(C) what (if anything) will be returned
A, B, C should all be included
Looking at the above documentation here, what else should be included here (in place of the question marks)?
number
string
list
Can be either number, string, or list (depends)
Before adding a function to a library, check for any use of a local variables within the function. If there is, rework the function using global variables and a return.
True
False
Before adding a function to a library, check if another function is called in this function. If so, both functions should be included in the library.
True
False
When creating a library (check all that apply):
Same as functions; do not start with a Capital Letter
Same as a function; no spaces in the library name
"Library" must be included in the name
Include what type of value the return and/or parameter has (ex. string)
When we organize functions into a library and then call them in another program, we are really practicing this (check all that apply):
Modularity
API
Library
Procedural Abstraction
What are the benefits of using existing algorithms instead of brand new algorithms (check all that apply)?
reduced development time
reduced testing
simplification and identification of errors
Explore all questions with a free account