Modularity in Game Development
- 97Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
97 questions
- 1The programming strategy of breaking a large problem into smaller parts is called_____.
Hint
Think of organizing a complex program into manageable components.
Answer
modularity
Explanation
Modularity means breaking a large programming problem into smaller components that can be developed separately.
- 2In a role-playing game, activities such as farming, fishing, mining, and crafting are examples of high-level_____.
Hint
These group related activities before they are split into smaller actions.
Answer
categories
Explanation
Broad categories organize a game’s functionality before each category is divided into specific tasks.
- 3Within farming, actions such as planting, watering, and harvesting are examples of smaller_____.
Hint
They are more specific tasks within a broader activity.
Answer
sub-problems
Explanation
Breaking a category such as farming into actions creates smaller sub-problems that can be tackled individually.
- 4Modularity lets programmers focus on solving each smaller task in_____rather than juggling the whole program at once.
Hint
The task is handled separately from the rest of the system.
Answer
isolation
Explanation
A programmer can work on one sub-problem at a time, independently of the larger program.
- 5If harvesting returns vegetables based on how well a plant was cared for, that is an example of implementing a small_____.
Hint
It is one specific piece of the larger farming system.
Answer
sub-problem
Explanation
The harvesting behavior is a smaller task than implementing all farming mechanics or an entire game.
- 6Separate farming and fishing components can be owned by different teams, making modularity helpful for_____.
Hint
Think about multiple programmers working on different parts of a project.
Answer
collaboration
Explanation
Modular components let teams work on separate areas, reducing the need to coordinate every code change directly.
- 7When developers work on separate components, they can focus on their tasks with less concern about code_____.
Hint
These can occur when separate contributions interfere with one another.
Answer
conflicts
Explanation
Separating components helps programmers avoid conflicting with teammates’ code while they work independently.
- 8Testing small components separately makes it easier to determine whether a particular piece of code works and to_____.
Hint
This is the process of locating and fixing errors.
Answer
debug
Explanation
A focused test of a small component makes errors easier to identify than testing an entire large program at once.
- 9Testing individual car components, such as brakes and transmission, illustrates the value of testing software_____.
Hint
The analogy checks parts of a system rather than only testing the whole system.
Answer
components
Explanation
Like testing car parts individually, software components can be checked separately; working parts increase confidence in the whole system.
- 10Organizing code by task makes it more readable and easier to find because it is no longer one giant_____.
Hint
The word describes disorganized code that is difficult to navigate.
Answer
mess
Explanation
Modular organization groups code by functionality, making the program easier to navigate and work with.
- 11A function is a named block of code that performs a specific_____.
Hint
It describes the purpose the block of code carries out.
Answer
task
Explanation
A function packages instructions under a name so that a particular task can be performed when needed.
- 12Defining a function once lets a programmer execute its task repeatedly without rewriting the same code, reducing_____.
Hint
This is what happens when the same instructions are written again and again.
Answer
repetition
Explanation
A function can be called multiple times, so its instructions do not need to be duplicated throughout a program.
- 13A function gives a name to a set of instructions in much the same way a variable gives a name to a_____.
Hint
A variable can refer to data stored in a program.
Answer
value
Explanation
A variable names a value, while a function names a set of instructions for performing a task.
- 14Values supplied to a function allow its task to be generalized; these inputs are called_____.
Hint
They are passed into a function call.
Answer
arguments
Explanation
Arguments are the input values supplied when a function is called, allowing it to work with different data.
- 15The named variables specified in a function definition to receive input values are called_____.
Hint
They correspond to the inputs provided when the function is called.
Answer
parameters
Explanation
Parameters are variables in the function definition that receive the corresponding argument values.
- 16In Python, a function definition begins with the keyword_____.
Hint
This keyword is short for “define.”
Answer
def
Explanation
Python uses the keyword def to introduce a function definition.
- 17The function name, parentheses, and colon at the start of a definition form the function_____.
Hint
It is the line that introduces the function before its indented body.
Answer
header
Explanation
The function header contains the definition keyword, function name, parameter parentheses, and colon.
- 18The indented instructions that perform a function’s task make up its function_____.
Hint
It is the code underneath the function header.
Answer
body
Explanation
Python identifies the function body by its indentation beneath the function header.
- 19Parameters behave like variables that are accessible only within the function body; they have local_____.
Hint
This term describes the region where a name can be accessed.
Answer
scope
Explanation
A parameter is available within its function’s local region, not automatically throughout the program.
- 20A function uses the keyword_____to specify the output value it sends back to its caller.
Hint
This keyword ends the function’s work and provides a result.
Answer
return
Explanation
The value following return becomes the output value of the function call.
- 21A function definition describes how to perform a task, while a function_____actually performs it.
Hint
The program uses the function’s name and parentheses to do this.
Answer
call
Explanation
Defining a function teaches the computer its instructions; calling the function executes them.
- 22A function definition must appear before its function calls so the computer has learned the task before it tries to_____.
Hint
The computer cannot perform instructions it has not yet encountered in the program.
Answer
execute it
Explanation
In the described Python execution model, the definition needs to be processed before the function is called.
- 23When a function is called, arguments are bound to the corresponding parameters in_____.
Hint
The first supplied input matches the first parameter, and so on.
Answer
order
Explanation
Arguments are assigned to parameters by position: the first argument goes to the first parameter, and subsequent arguments follow in sequence.
- 24When a function call finishes, its expression evaluates to the value supplied by the function’s_____.
Hint
It is the instruction that provides the function’s output.
Answer
return statement
Explanation
The returned value replaces the function-call expression in the surrounding code.
- 25When the computer first encounters a function definition, it records the instructions but does not yet_____the function body.
Hint
At this point, the computer is learning the task rather than carrying it out.
Answer
execute
Explanation
Processing a definition makes the function available; the body runs only when the function is called.
- 26When a function call begins, the computer creates an isolated region of short-term memory called a_____.
Hint
It stores the local state for one function call.
Answer
stack frame
Explanation
A stack frame is a separate memory area used to hold a function call’s arguments, parameters, and local variables.
- 27The computer copies each call’s input values into its stack frame and associates them with the corresponding_____.
Hint
These names appear in the function definition.
Answer
parameter names
Explanation
Arguments are stored in the new frame under the names of their corresponding parameters.
- 28A function’s return statement transfers execution back to the function’s_____.
Hint
This is the location in the program where the function was called.
Answer
call site
Explanation
After computing the return value, the computer resumes execution at the line that made the call.
- 29When a function returns, its stack frame is popped off and its local memory is_____.
Hint
The function’s temporary state does not remain available after it ends.
Answer
cleared
Explanation
Returning ends that function call, removing its stack frame and its local variables from active memory.
- 30A returned value can be stored in a variable at the call site, while a returned value that is not used is effectively_____.
Hint
The function computed it, but the program did not save or use it.
Answer
lost
Explanation
A function call can produce a value without the surrounding code storing it; in that case the result is discarded.
- 31User-defined function definitions are not remembered across separate program executions, so they must be processed each time the program_____.
Hint
The computer’s memory for one execution does not persist into the next.
Answer
runs
Explanation
The computer clears its program memory when execution terminates, so it must learn the user-defined functions again on the next run.
- 32A variable’s scope is the region of a program where that variable can be_____.
Hint
Scope determines where a name can be used.
Answer
accessed
Explanation
The scope of a variable describes the part of the program in which the variable is available.
- 33Names defined at the top level of a program are in_____scope.
Hint
This is the program-wide scope outside function-local regions.
Answer
global
Explanation
Top-level names are stored in global scope and can be accessed from different parts of the program, subject to name lookup rules.
- 34Variables assigned within a function call are normally stored in the function’s_____scope.
Hint
This scope belongs to a particular function region.
Answer
local
Explanation
Function parameters and local assignments are stored in the function’s own stack frame, separate from global scope.
- 35If a function assigns to a local variable with the same name as a global variable, it creates a separate local name rather than automatically overwriting the_____.
Hint
The two names live in different scopes.
Answer
global variable
Explanation
A local assignment affects the function’s local variable; it does not by itself update a same-named global variable.
- 36When a function returns, its local variables disappear because the function’s_____.
Hint
The local memory for the completed call is removed.
Answer
stack frame is popped
Explanation
Popping the stack frame removes the local variables associated with that function call.
- 37The reliable way for a function to communicate a calculated result back to its caller is through its_____.
Hint
It is the output channel of the function.
Answer
return value
Explanation
Local assignments do not automatically change global state; a function should return information for the caller to use.
- 38Python’s global keyword can allow a function to access a global variable explicitly, but good practice is to use it_____.
Hint
The lesson warns against relying on this mechanism in most cases.
Answer
rarely
Explanation
Changing global state can create naming conflicts and hidden dependencies, so the global keyword should almost never be needed.
- 39Keeping variables local allows different functions to reuse variable names without requiring every name in the program to be globally_____.
Hint
Local scopes prevent names from colliding across functions.
Answer
unique
Explanation
Local scope reduces naming conflicts because a name used in one function need not differ from names in unrelated functions.
- 40When Python cannot find a name in the current local scope, it searches the next closest enclosing scope, such as_____.
Hint
This is the broader scope outside the function.
Answer
global scope
Explanation
Name lookup starts in the closest scope and proceeds outward to enclosing scopes; a global name can therefore be read if no local name shadows it.
- 41If name lookup fails in every available scope, Python raises a_____.
Hint
It indicates that the requested name could not be found.
Answer
NameError
Explanation
Python raises a NameError when it runs out of scopes to search without finding the requested name.
- 42Passing needed information into a function through parameters avoids hidden dependence on variables in_____.
Hint
This is information outside the function’s local region.
Answer
global scope
Explanation
Explicit parameters make a function’s requirements clear to its callers and avoid assuming that particular global variables exist.
- 43When one function calls another, the inner call creates a new stack frame on top of the still-active_____.
Hint
The calling function has not finished executing yet.
Answer
outer stack frame
Explanation
The computer preserves the caller’s frame while the nested function runs, then resumes the caller after the nested call returns.
- 44After a nested function returns, the computer removes its top stack frame and resumes the calling function where it_____.
Hint
The outer function’s state is preserved while the inner function runs.
Answer
left off
Explanation
The outer frame remains intact during the nested call, allowing execution to continue from the point of interruption.
- 45Each stack frame tracks variables local to a particular function_____.
Hint
A function invoked multiple times receives separate execution state for each one.
Answer
call
Explanation
A new frame is created on each call, keeping that call’s local variables separate from other calls.
- 46A long function that calculates footstep volume, adjusts it for the environment, and checks detection is harder to read because it performs several_____.
Hint
The function has more than one responsibility.
Answer
tasks
Explanation
A function with many responsibilities obscures what its name means and makes its behavior harder to understand.
- 47Splitting movement-based footstep volume into its own function makes it easier to test that crouching is quieter and running is_____.
Hint
Compare the sound of moving slowly and carefully with moving quickly.
Answer
louder
Explanation
A movement-volume function can be checked directly with different movement types, such as expecting a higher volume for running than crouching.
- 48A separate environment function can take a volume and environment type, then return the_____.
Hint
It gives back the volume after accounting for the surroundings.
Answer
adjusted volume
Explanation
Separating the environmental adjustment into its own function isolates that specific task.
- 49A reusable detection function can take a volume and return a Boolean indicating whether the player is_____.
Hint
It answers whether guards notice the player.
Answer
detected
Explanation
Decoupling the threshold check from volume calculation lets the same detection logic be reused with different sound sources.
- 50Function names that clearly state their tasks can make code self-documenting, reducing the need for explanatory_____.
Hint
These are written notes in the source code.
Answer
comments
Explanation
Descriptive function names communicate what the code does, so the code may not need as many comments to explain each operation.
- 51Separating volume calculation from detection makes it easier to reuse the detection logic for a player’s_____.
Hint
This is another sound source that could alert guards.
Answer
voice
Explanation
A voice’s volume can be calculated separately and passed to the same independent detection function.
- 52A function should consistently return the same kind of data so that callers know what to_____.
Hint
Consistency makes it predictable how a result can be used.
Answer
expect
Explanation
If a function sometimes returns a number and sometimes a string, callers may encounter errors when they handle the result.
- 53In the card example, a playing card is represented as a string composed of its rank and its_____.
Hint
Hearts, diamonds, spades, and clubs are examples.
Answer
suit
Explanation
The card-drawing design combines a randomly chosen suit with a randomly chosen rank.
- 54A standard playing card has four possible suits: hearts, diamonds, spades, and_____.
Hint
It is the remaining suit in the familiar four-suit deck.
Answer
clubs
Explanation
The four suits used in the example are hearts, diamonds, spades, and clubs.
- 55A card’s rank can be ace, two through ten, jack, queen, or king, giving_____possible ranks.
Hint
Count ace, the numbered ranks, and the three other face cards.
Answer
13
Explanation
The example identifies thirteen ranks: ace, two through ten, jack, queen, and king.
- 56The get-rank function should convert a numeric rank to a string so that it can be combined with the other card text without a_____.
Hint
This error can occur when incompatible data types are combined.
Answer
TypeError
Explanation
Returning an integer for numbered ranks while returning strings for face ranks can cause a TypeError when constructing a card string.
- 57A Boolean option that controls whether face cards are allowed can make the rank-drawing function more_____.
Hint
The function can support different game rules through an input choice.
Answer
generalizable
Explanation
A Boolean parameter allows callers to choose whether the generated rank may include face cards.
- 58When face cards are disabled, choosing a random number from two through ten excludes ranks one, eleven, twelve, and_____.
Hint
This is the numeric value assigned to king in the example.
Answer
13
Explanation
The restricted range from two through ten leaves out ace, jack, queen, and king, represented by one and eleven through thirteen.
- 59If a function needs a caller’s choice about whether face cards are enabled, the caller’s choice should be passed through as a function_____.
Hint
The function receives this named input when it is called.
Answer
parameter
Explanation
A parameter lets the caller supply the option, and the value can then be passed on to another function that needs it.
- 60A deck model that selects cards independently without tracking previously drawn cards is not_____.
Hint
It does not remember which cards have already been drawn.
Answer
stateful
Explanation
Because the example does not maintain deck state, it can produce duplicate cards even when a single physical deck would not.
- 61Allowing duplicate cards can be suitable for games that use multiple decks, but it can be a bug when rules require exactly_____.
Hint
This is the condition expected of a single standard deck.
Answer
one of each card
Explanation
Whether duplicates are acceptable depends on the game’s requirements and use case.
- 62A Python module is created by putting code in a new file with the_____.
Hint
This file ending tells Python that the file contains Python code.
Answer
.py extension
Explanation
A module is a Python file, conventionally identified by its .py file extension.
- 63The file that serves as the program’s starting point is called the entry point or_____.
Hint
It is the one file selected to begin program execution.
Answer
main logic
Explanation
Although program code can span many modules, execution begins from a single entry-point file, conventionally named main.py.
- 64An import statement makes a module available to the program; calling one of its functions typically uses the_____before the function name.
Hint
It identifies which file’s namespace contains the function.
Answer
module name
Explanation
A module-qualified call uses the module name to access a function defined in that module.
- 65Importing a module is similar to copying its contents into the importing program, but module names remain separated by_____.
Hint
This boundary keeps names defined in different files distinct.
Answer
scope
Explanation
Module scope places names under their module’s namespace, preventing unrelated files’ names from automatically colliding.
- 66In Nim, players remove one or two stones on each turn, and the player who removes the last stone_____.
Hint
The goal is to avoid taking the final stone.
Answer
loses
Explanation
The Nim rules described make taking the final stone a losing move.
- 67In the Nim program, a loop continues while the number of stones in the pile is_____.
Hint
The game continues as long as stones remain.
Answer
greater than zero
Explanation
The while-loop condition checks whether the pile still contains stones before another turn is played.
- 68A Boolean variable can track whose turn it is because the game has_____possible player states.
Hint
The states correspond to the user and the computer.
Answer
two
Explanation
A Boolean can represent the user’s turn as true and the computer’s turn as false, or vice versa.
- 69The turn indicator should switch to the other player after each turn so the program can_____.
Hint
The user and computer take turns rather than acting consecutively.
Answer
alternate players
Explanation
Changing the Boolean turn value at the loop’s end transfers play to the other player.
- 70The computer should not take a turn after the user removes the last stone because the game is already_____.
Hint
No further move should occur once the pile is empty.
Answer
over
Explanation
The program alternates turns, but the computer must not move after the user ends the game by taking the last stone.
- 71To make the Nim pile less predictable, the program can choose its initial size_____.
Hint
The pile size should vary between games rather than always start the same way.
Answer
randomly
Explanation
Randomizing the initial number of stones makes repeated games less predictable.
- 72If the computer faces one stone, it must pick one; if it faces two stones, its best move is also to pick_____.
Hint
This leaves the opponent with the final stone in the two-stone case.
Answer
one
Explanation
With two stones remaining, taking one leaves one for the opponent, who then loses by taking it.
- 73With three stones remaining, the computer should take two to leave the opponent with_____.
Hint
The opponent is then forced to take the final stone.
Answer
one stone
Explanation
Taking two from a pile of three leaves one, which the opponent must take and lose on.
- 74With four stones remaining, taking either one or two lets the opponent respond so that the current player is left with the final_____.
Hint
Both possible first moves can give the opponent a way to leave one behind.
Answer
stone
Explanation
If a player takes one, the opponent can take two; if the player takes two, the opponent can take one. In either case, the first player is left to take the last stone.
- 75The Nim analysis treats leaving the opponent with four stones as a winning position because the opponent can be forced to take the_____.
Hint
This is the losing move under the game’s rules.
Answer
last stone
Explanation
From a pile of four, every permitted move gives the other player a response that can leave the first player with the final stone.
- 76In the example’s partial computer strategy, piles of one, two, or five stones lead the computer to pick_____.
Hint
These are the cases assigned the smaller of the two legal moves.
Answer
one stone
Explanation
The described algorithm selects one stone when the remaining pile size is one, two, or five.
- 77In the example’s partial computer strategy, piles of three or six stones lead the computer to pick_____.
Hint
These are the cases assigned the larger of the two legal moves.
Answer
two stones
Explanation
The described algorithm selects two stones when the remaining pile size is three or six.
- 78The best move for the computer when the pile has eight or nine stones is posed as an exercise, and the broader strategy can be found by looking for a_____.
Hint
Map out more pile sizes to identify repeating structure.
Answer
pattern
Explanation
The example suggests analyzing additional positions to discover a pattern that can improve the computer’s algorithm.
- 79A unit test checks a single unit of functionality at a time, which in most cases is a_____.
Hint
It is a named block of code that performs a particular task.
Answer
function
Explanation
Unit testing focuses on small units of behavior, most often individual functions.
- 80A unit test encodes a function’s requirements by calling it with inputs and checking its_____.
Hint
The test compares the actual output with the expected output.
Answer
return value
Explanation
A test passes when the function’s actual result matches the result required by the test.
- 81If a function’s result differs from what its test expects, the test_____.
Hint
This is the opposite of passing.
Answer
fails
Explanation
A test fails when the actual behavior does not satisfy the expected result or assertion.
- 82Automated unit tests can run whenever code changes and block submission until related tests_____.
Hint
The team requires the checks to succeed before accepting the change.
Answer
pass
Explanation
Running tests during development can enforce requirements and prevent changes that break existing behavior from being submitted.
- 83A unit test suite can act as a living contract for a function’s_____.
Hint
These specify the behavior the function is expected to have.
Answer
requirements
Explanation
Tests document expected behavior in executable form and can be updated when requirements intentionally change.
- 84A single test case provides weak evidence about a function because a function that always returns one fixed value could still pass it; a stronger strategy aims for code_____.
Hint
It measures whether the tests exercise the program’s possible execution paths.
Answer
coverage
Explanation
A test suite should cover meaningful behaviors and branches rather than relying on a single example input.
- 85A goal of code coverage is to make test cases execute every possible path of_____through a function.
Hint
This is the route the computer takes through the function’s branches and instructions.
Answer
execution
Explanation
Testing representative inputs for each branch helps exercise the function’s different execution paths.
- 86For a function with conditional branches based on train counts, test cases should represent each distinct class of_____.
Hint
These are grouped according to which branch they trigger.
Answer
inputs
Explanation
Representative input classes, such as each range of train counts, help cover the function’s conditional branches.
- 87When a bug is discovered, adding a test for that exact failure case helps ensure the same bug does not happen_____.
Hint
The new test guards against a repeat of the problem.
Answer
twice
Explanation
A regression test records the failure case so later changes can be checked against it.
- 88Python programmers commonly use the unit test module or the_____module for unit testing.
Hint
It is another popular Python testing framework named in the lesson.
Answer
py test
Explanation
The lesson identifies the unit test and py test modules as common Python testing choices.
- 89When reading a stack trace, the bottom often identifies the actual error and the line where it occurred; the rest describes the path of_____.
Hint
It traces how the program reached the failing line.
Answer
execution
Explanation
The lower portion of the trace provides the immediate error details, while the other entries show the sequence of calls that led there.
- 90For an independent learner, manually calling a function with several different arguments can be useful even without writing automated_____.
Hint
These are formal, repeatable checks written in a testing framework.
Answer
unit tests
Explanation
Trying multiple inputs helps verify expected behavior and build confidence even when a learner does not automate tests.
- 91Testing functions individually while building a program makes later debugging easier because correctly tested functions can be ruled out as the cause of a_____.
Hint
This is an error in the program’s behavior.
Answer
bug
Explanation
Confidence in smaller tested units narrows the search when an error appears elsewhere in the larger program.
- 92In the racing-game example, the display function takes car positions and track length, then returns a string drawing of the track_____.
Hint
It shows where the cars are relative to the track.
Answer
state
Explanation
The display function represents the current positions of the cars as a textual view of the track.
- 93Testing the display function in isolation revealed that a car could disappear when its position was beyond the track’s_____.
Hint
The original drawing loop stopped at the end of the track.
Answer
length
Explanation
The function’s loop initially drew only through the track endpoint, so it could omit a car positioned farther ahead.
- 94To display a car beyond the track endpoint, the drawing loop should continue to the greatest of the track length and both car_____.
Hint
The furthest car determines how far the drawing must extend.
Answer
positions
Explanation
Taking the maximum of the track length and the two car positions ensures the displayed segments reach the furthest relevant point.
- 95When both cars occupy the same track space, a display function can show a special symbol such as_____.
Hint
The example uses this mark to represent both cars together.
Answer
X
Explanation
A distinct symbol makes it possible to show that both cars share a position instead of displaying only one car’s symbol.
- 96To draw the shared-position symbol only in the correct segment, the display logic must check that the current position matches both car_____.
Hint
It is not enough for the cars to match each other; the segment being drawn must match too.
Answer
positions
Explanation
The symbol should appear only when the segment position equals the position of both cars.
- 97Breaking a suspected problem down to the individual function level makes it easier to test and debug that single_____.
Hint
This is the small piece of functionality under investigation.
Answer
unit
Explanation
Isolating a function narrows the problem and lets the programmer focus on one piece of behavior at a time.

Ask anything
We've read this whole study set, so questions about it get the best answers.