Deck 6: Design With Functions

Full screen (f)
exit full mode
Question
Recursive functions are frequently used to design algorithms for computing values that have a recursive definition.
Use Space or
up arrow
down arrow
to flip the card.
Question
The assignment of roles and responsibilities to different actors in a program is also called responsibility-driven design.
Question
When you design an algorithm, it should be general enough to provide a solution to many problem instances, not just one or a few of them.
Question
The use of a common pool of data allows a program to grow easily as new data sources are added to the program.
Question
Like with an infinite loop, an infinite recursion eventually halts execution with an error message.
Question
Each box in a structure chart is labeled with a module name.
Question
Recursive functions tend to be more complicated than the corresponding loops.
Question
The amount of memory needed for a loop grows with the size of the problem's data set.
Question
When a call returns or completes its execution, the memory for the stack frame is reallocated.
Question
A function call expresses the idea of a process to the programmer, forcing him or her to wade through the complex code that realizes that idea.
Question
The first five numbers of the Fibonacci sequence are 1 3 5 8 13.
Question
In a case of infinite recursion, the Python virtual machine eventually runs out of memory resources to manage the process, so it halts execution with an error message.
Question
An abstraction hides detail and thus allows a person to view many things as just one thing.
Question
To get a better understanding of how recursion works, it is helpful to trace its calls.
Question
A recursive function must contain at least one repetition statement.
Question
Most recursive functions expect no arguments.
Question
In bottom-up design, you decompose a complex problem into a set of simpler problems and solve these with different functions.
Question
It is possible to construct any algorithm using only Python's built-in operators and control statements.
Question
Recursive solutions are often more natural and elegant than their iterative counterparts.
Question
A black-box chart is a diagram that shows the relationships among a program's functions and the passage of data between them.
Question
How does top-down design work?

A) A problem is solved by employing a large task force to evaluate the cause.
B) A problem is solved by redesigning and repurposing existing software.
C) A solution is created to solve a problem, and individual issues are resolved as they are encountered.
D) A problem is decomposed into smaller problems, which are gradually solved to produce a solution.
Question
In a recursive function, what is used to determine whether to stop or to continue with another recursive step?

A) terminator value
B) base case
C) recursion factor
D) step counter
Question
Where can the required arguments for a function be found?

A) In the function header.
B) In the module docstring.
C) In the function keyword list.
D) In the function's return list.
Question
What is the name for a diagram that shows the relationships among a program's functions and the passage of data between them?

A) data map
B) structure map
C) structure chart
D) program flowchart
Question
For each call of a function, the Python virtual machine must allocate a small chunk of memory on the call stack, which is known by what term?

A) stack chunk
B) stack frame
C) data nibble
D) memory slice
Question
A Python function cannot under normal circumstances reference a module variable for its value.
Question
The process of hiding a complex process by developing a mechanism to simplify or hide that process is known by what term?

A) simplification
B) obfuscation
C) abstraction
D) diffraction
Question
What is the purpose of a higher-order function?

A) It separates the task of transforming data values from the logic of accumulating the results.
B) It is a mutator that can be utilized on functions to remove redundant patterns in code.
C) It allows the definition of specialized ordering logic for data sets.
D) It is a special function that ignores program scope and has access to localized variables.
Question
In Python, functions are treated as first-class data objects. What does this mean?

A) It means that they are considered to be global variables inside any Python code.
B) It means that the functions are given higher priority over resource access than regular chunks of code.
C) It means that functions are protected objects and are not easily imported from other modules, unless the author desires it.
D) It means that functions can be assigned to variables, passed as arguments to other functions, returned as values, and stored in data structures.
Question
The assignment of roles and responsibilities to different actors in a program is known as what type of design?

A) role-based access design
B) responsibility-driven design
C) delegated assignment design
D) task abstraction design
Question
What is the call stack used for in the Python virtual machine?

A) The call stack is an area of reserved memory used to store chunks of memory related to functions.
B) The call stack is an area of reserved memory used to perform system calls for access to hardware.
C) The call stack is a log of called functions and methods within the program.
D) The call stack is a temporary storage area for junk data.
Question
Smart compilers exist that can optimize some recursive functions by translating them to iterative machine code.
Question
What type of error is raised when the Python virtual machine runs out of memory resources to manage a process?

A) runaway process error
B) out of memory error
C) input output error
D) stack overflow error
Question
The Fibonacci sequence is a series of values that can be easily calculated with what kind of function?

A) recursive function
B) repeating function
C) duplicating function
D) compounding function
Question
A method reference always uses an object, which can be denoted by a string followed by a dot and the method name.
Question
What happens when a function tries to assign or change a value of a variable that has been defined at the module level?

A) The function succeeds, because the module variable is considered global in scope.
B) The function succeeds, but the value is appended to the variable.
C) The function fails, and an out of scope error message is raised.
D) Python creates a temporary variable with the same name, and the value of that variable exists only within the scope of the function.
Question
A program's namespace is the set of its variables and their values.
Question
What are two common methods by which functions serve as abstraction mechanisms? (Choose two.)

A) The elimination of redundant, or repetitious code.
B) The availability of detailed docstring data.
C) The hiding of complicated processes.
D) The use of a bottom-up approach to design.
Question
When using functions that have default arguments, the required arguments must be provided and must be placed in the same positions as they are in the function definition's header.
Question
What can often provide you with a pattern for designing the structure of a program?

A) The structure of the problem you're attempting to solve.
B) The structure of code written by other people.
C) The structure of an organization's workforce.
D) The structure of the programming language used.
Question
The gradual process of developing functions to solve each subproblem in a top-down design is known as what process?

A) procedural refinement
B) stepwise refinement
C) progressing resolution
D) incremental solving
Question
What makes up a Python program's namespace?

A) The combination of all included modules and their functions.
B) The set of all its variables and their values.
C) The defined methods of the program.
D) The main method of the program itself.
Question
In what higher-order function do you apply a predicate to each value within a list, and if the predicate returns true, the value is added to an object?

A) mapping
B) filtering
C) reducing
D) associating
Question
What higher-order function process applies a function to each value in a sequence and returns a new sequence of the results?

A) mapping
B) filtering
C) reducing
D) associating
Question
In Python, what is the term that is used to describe the area of a program text in which an object name refers to a given value?

A) relation
B) relevance
C) lifetime
D) scope
Question
What are the two different ways that default arguments can be provided to a function? (Choose two.)

A) By supplying arguments in which they occur in the function header.
B) By using a reference pointer variable.
C) By overloading the function and redefining the arguments.
D) By assigning values to the keys in the function header.
Question
What term describes a dictionary of functions keyed by command names?

A) command table
B) jump table
C) skip table
D) function table
Question
Which of the following statements are accurate? (Choose two.)

A) Parameters for a function receive values when they are declared.
B) When module variables are introduced in a program, they are immediately given a value.
C) A nested variable can assign value to a variable outside of its scope.
D) Temporary values receive their values as soon as they are introduced.
Question
What is the lambda function in Python utilized for?

A) It allows for the creation of an anonymous function, which contains the names of its arguments and a single expression.
B) It creates an overloaded function, such that the function can be repurposed on the fly.
C) It allows for the tracking of use of a targeted function.
D) It allows for multiple higher-order functions to be utilized on the same selection statements.
Question
What higher-order function takes a list of values and repeatedly applies a function to accumulate a single data value?

A) mapping
B) filtering
C) reducing
D) associating
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Design With Functions
1
Recursive functions are frequently used to design algorithms for computing values that have a recursive definition.
True
2
The assignment of roles and responsibilities to different actors in a program is also called responsibility-driven design.
True
3
When you design an algorithm, it should be general enough to provide a solution to many problem instances, not just one or a few of them.
True
4
The use of a common pool of data allows a program to grow easily as new data sources are added to the program.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Like with an infinite loop, an infinite recursion eventually halts execution with an error message.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
Each box in a structure chart is labeled with a module name.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
Recursive functions tend to be more complicated than the corresponding loops.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
The amount of memory needed for a loop grows with the size of the problem's data set.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
When a call returns or completes its execution, the memory for the stack frame is reallocated.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
A function call expresses the idea of a process to the programmer, forcing him or her to wade through the complex code that realizes that idea.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
The first five numbers of the Fibonacci sequence are 1 3 5 8 13.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
In a case of infinite recursion, the Python virtual machine eventually runs out of memory resources to manage the process, so it halts execution with an error message.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
An abstraction hides detail and thus allows a person to view many things as just one thing.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
To get a better understanding of how recursion works, it is helpful to trace its calls.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
A recursive function must contain at least one repetition statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
Most recursive functions expect no arguments.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
In bottom-up design, you decompose a complex problem into a set of simpler problems and solve these with different functions.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
It is possible to construct any algorithm using only Python's built-in operators and control statements.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
Recursive solutions are often more natural and elegant than their iterative counterparts.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
A black-box chart is a diagram that shows the relationships among a program's functions and the passage of data between them.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
How does top-down design work?

A) A problem is solved by employing a large task force to evaluate the cause.
B) A problem is solved by redesigning and repurposing existing software.
C) A solution is created to solve a problem, and individual issues are resolved as they are encountered.
D) A problem is decomposed into smaller problems, which are gradually solved to produce a solution.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
In a recursive function, what is used to determine whether to stop or to continue with another recursive step?

A) terminator value
B) base case
C) recursion factor
D) step counter
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
Where can the required arguments for a function be found?

A) In the function header.
B) In the module docstring.
C) In the function keyword list.
D) In the function's return list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
What is the name for a diagram that shows the relationships among a program's functions and the passage of data between them?

A) data map
B) structure map
C) structure chart
D) program flowchart
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
For each call of a function, the Python virtual machine must allocate a small chunk of memory on the call stack, which is known by what term?

A) stack chunk
B) stack frame
C) data nibble
D) memory slice
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
A Python function cannot under normal circumstances reference a module variable for its value.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
The process of hiding a complex process by developing a mechanism to simplify or hide that process is known by what term?

A) simplification
B) obfuscation
C) abstraction
D) diffraction
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
What is the purpose of a higher-order function?

A) It separates the task of transforming data values from the logic of accumulating the results.
B) It is a mutator that can be utilized on functions to remove redundant patterns in code.
C) It allows the definition of specialized ordering logic for data sets.
D) It is a special function that ignores program scope and has access to localized variables.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
In Python, functions are treated as first-class data objects. What does this mean?

A) It means that they are considered to be global variables inside any Python code.
B) It means that the functions are given higher priority over resource access than regular chunks of code.
C) It means that functions are protected objects and are not easily imported from other modules, unless the author desires it.
D) It means that functions can be assigned to variables, passed as arguments to other functions, returned as values, and stored in data structures.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
The assignment of roles and responsibilities to different actors in a program is known as what type of design?

A) role-based access design
B) responsibility-driven design
C) delegated assignment design
D) task abstraction design
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
What is the call stack used for in the Python virtual machine?

A) The call stack is an area of reserved memory used to store chunks of memory related to functions.
B) The call stack is an area of reserved memory used to perform system calls for access to hardware.
C) The call stack is a log of called functions and methods within the program.
D) The call stack is a temporary storage area for junk data.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
Smart compilers exist that can optimize some recursive functions by translating them to iterative machine code.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
What type of error is raised when the Python virtual machine runs out of memory resources to manage a process?

A) runaway process error
B) out of memory error
C) input output error
D) stack overflow error
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
The Fibonacci sequence is a series of values that can be easily calculated with what kind of function?

A) recursive function
B) repeating function
C) duplicating function
D) compounding function
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
A method reference always uses an object, which can be denoted by a string followed by a dot and the method name.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
What happens when a function tries to assign or change a value of a variable that has been defined at the module level?

A) The function succeeds, because the module variable is considered global in scope.
B) The function succeeds, but the value is appended to the variable.
C) The function fails, and an out of scope error message is raised.
D) Python creates a temporary variable with the same name, and the value of that variable exists only within the scope of the function.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
A program's namespace is the set of its variables and their values.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
What are two common methods by which functions serve as abstraction mechanisms? (Choose two.)

A) The elimination of redundant, or repetitious code.
B) The availability of detailed docstring data.
C) The hiding of complicated processes.
D) The use of a bottom-up approach to design.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
When using functions that have default arguments, the required arguments must be provided and must be placed in the same positions as they are in the function definition's header.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
What can often provide you with a pattern for designing the structure of a program?

A) The structure of the problem you're attempting to solve.
B) The structure of code written by other people.
C) The structure of an organization's workforce.
D) The structure of the programming language used.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
The gradual process of developing functions to solve each subproblem in a top-down design is known as what process?

A) procedural refinement
B) stepwise refinement
C) progressing resolution
D) incremental solving
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
What makes up a Python program's namespace?

A) The combination of all included modules and their functions.
B) The set of all its variables and their values.
C) The defined methods of the program.
D) The main method of the program itself.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
In what higher-order function do you apply a predicate to each value within a list, and if the predicate returns true, the value is added to an object?

A) mapping
B) filtering
C) reducing
D) associating
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
What higher-order function process applies a function to each value in a sequence and returns a new sequence of the results?

A) mapping
B) filtering
C) reducing
D) associating
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
In Python, what is the term that is used to describe the area of a program text in which an object name refers to a given value?

A) relation
B) relevance
C) lifetime
D) scope
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
What are the two different ways that default arguments can be provided to a function? (Choose two.)

A) By supplying arguments in which they occur in the function header.
B) By using a reference pointer variable.
C) By overloading the function and redefining the arguments.
D) By assigning values to the keys in the function header.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
What term describes a dictionary of functions keyed by command names?

A) command table
B) jump table
C) skip table
D) function table
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Which of the following statements are accurate? (Choose two.)

A) Parameters for a function receive values when they are declared.
B) When module variables are introduced in a program, they are immediately given a value.
C) A nested variable can assign value to a variable outside of its scope.
D) Temporary values receive their values as soon as they are introduced.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
What is the lambda function in Python utilized for?

A) It allows for the creation of an anonymous function, which contains the names of its arguments and a single expression.
B) It creates an overloaded function, such that the function can be repurposed on the fly.
C) It allows for the tracking of use of a targeted function.
D) It allows for multiple higher-order functions to be utilized on the same selection statements.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
What higher-order function takes a list of values and repeatedly applies a function to accumulate a single data value?

A) mapping
B) filtering
C) reducing
D) associating
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.