1/103
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Control structure
It is a fundamental component that determines the flow of execution of instructions in a program. It governs which instructions are executed, when, and under what conditions.
Control structure
It allows programs to make decisions, perform repeated tasks, and respond dynamically to different inputs or conditions—essential for building complex, responsive software.
Sequential Structure
This is the simplest form of control where statements or instructions are executed one after another in the exact order in which they are written.
does not
Sequential structure is used to carry out a linear set of operations where the flow (does / does not) require any decision-making or repetition.
fixed sequence
Sequential structure is commonly applied in tasks that must be performed in a f______ s__________ with no deviation
Sequential Structure
This control structure is common in initialization routines, data input/output operations, and procedural steps.
Selection (Decision-Making) Structure
This executes a block of code only if a condition is true. It allows the program to choose between alternative paths of execution based on whether a condition is true or false. This enables decision-making capabilities in the program.
Selection (Decision-Making) Structure
This is commonly applied in scenarios requiring branching logic, such as validation checks, menu selections, or rule-based execution (e.g., user authentication and eligibility determination).
branching logic
Selection (Decision-Making) Structure is commonly applied in scenarios requiring b____________ l_______
Selection (Decision-Making) Structure
User authentication and eligibility determination is an example of which control structure?
If-else and if-elif-else
Selection (Decision-Making) Structure use the following keyword:
if
This keyword is used to begin a conditional block that runs if the condition is true
else
This keyword is used to execute its block if the condition is false.
elif
This keyword is short of “else if”
elif
This keyword is used to evaluate additional conditions if previous ones are false.
Iteration (Looping) Structure
This repeats a block of code as long as a specified condition is true. It is used to automate repetitive tasks without manual code duplication.
Iteration (Looping) Structure
It promotes efficiency and reduces errors by encapsulating repeat logic.
Iteration (Looping) Structure
This is commonly applied in traversing data structures, generating reports, implementing counters, or processing batches
Iteration (Looping) Structure
Looping through user records and retry mechanisms is an example of which control structure?
for and while
Iteration (Looping) Structure uses the following keyword:
for
This keyword begins the counting loop.
while
This keyword begins a loop that continues as long as the condition is true.
break, continue, return
Jump (Branching) Structure alters the flow explicitly using b____, c_________, r________, etc.
Jump (Branching) Structure
It interrupts or redirects the normal flow of control using statements that cause execution to jump to another part of the code.
loops, iterations, function
Jump (Branching) Structure provides exceptional flow control, particularly in exiting l______ early, skipping i____________, or terminating a f________.
break, continue
These keywords are used in loop control
return
This keyword is used in early function termination
error-handling, system-level
Jump (Branching) Structure is used in specific e_______ h_________ and s________ l_______operations (e.g., skipping invalid entries, exiting on critical errors).
break
This keyword terminates the loop immediately.
continue
This keyword is used to skip the current loop iteration and proceed to the next.
Subprogram
It is a named, self-contained block of code designed to execute a specific task within a larger program.
functions, procedures, or methods
It is also known as f___________, p___________, or m__________(depending on the language).
Subprogram
It allows programmers to group logically related operations and execute them whenever needed.
def
Subprograms are declared using the d___ keyword followed by a function name, a parameter list, and a block of statements.
Subprogram
These are fundamental constructs in all modern programming languages.
divide-and-conquer
Subprograms support the d_______ and c__________ approach by allowing a program to be decomposed into manageable units, which improves clarity, debugging, collaboration, and reuse.
Modularity
The main purpose of subprograms is to promote m__________.
Modularity
It is the process of breaking down a program into smaller, functional components.
understand and maintain
Code is easier to u__________ and m__________ because each subprogram handles a specific task.
once
Redundancy is reduced since frequently used operations can be written o____ and called many times.
isolated and verified
Testing and debugging are more efficient, as subprograms can be i__________ and v_______ independently.
smoother
Collaboration becomes s__________ since development teams can assign different subprograms to different members.
Mathematical Computation
Subprograms for operations like finding the square root, computing factorials, or evaluating mathematical expressions.
Data Handling
Functions for data validation, parsing, formatting, and transformation.
User Interface (UI)
Subprograms that handle events like button clicks, form submissions, or rendering interface components.
Web Development
Backend functions to process requests, interact with databases, and return responses to the user.
Software Application Programming Interface (API)
Subprograms expose functionality for external programs to reuse, like authentication, logging, or payment processing.
Game Development
Control mechanics such as character movement, score tracking, and level progression are often subprogram-based.
functions
Subprograms are implemented primarily through f_________.
value, arguments
Subprograms may or may not return v______ and can accept various a__________, including default, keyword, and variable-length parameters.
Parameter passing
It determines how arguments are transmitted from the caller to the subprogram.
Parameter passing
It affects whether modifications made inside the subprogram reflect outside and influences memory management and performance.
Pass-by-object-reference
Python uses a mechanism called "____ __ _______ ___________" (a mix of pass-by-value and pass-by-reference depending on mutability).
Pass-by-Value
Copies the value of the actual parameter. Changes in the function do not affect the original.
Pass-by-Value
Simulated with immutable types
Pass-by-Reference
Passes a reference (address) of the argument. Changes affect the original.
Pass-by-Reference
Simulated with mutable types
Pass-by-Result
A parameter acts like a placeholder to be filled with a result and returned.
Pass-by-Result
Not directly supported
Pass-by-Value-Result
Value is copied in, and the result is copied out after function execution.
Pass-by-Value-Result
Not natively supported
Pass-by-Value
Demonstrates that changes to parameters inside the function do not affect the original variable.
original data
Pass-by-Value is useful when protecting the o________ d_____ from unintended side effects.
immutable
Python integers are i____________, so num inside the function is a copy of x's value. This mimics pass-by-value.
Pass-by-Reference
Demonstrates how changes to a parameter inside a function affect the original variable when the parameter is mutable.
lists or dictionaries
Pass-by-Reference is useful for modifying data structures like l____ or d___________.
mutable
Since lists are m_________, Python passes a reference to the list, so operations inside the function apply to the original data.
Pass-by-Result (Simulated)
Illustrates how a function might assign a result to an initially empty or placeholder variable and return it. While Python does not support true pass-by-result, the behavior can be simulated by returning the result explicitly.
Pass-by-Value-Result (Simulated)
Mimics is a mechanism where a copy of the value is passed into the function, modified internally, and the updated result is explicitly returned and reassigned to the original.
reassigned
Pass-by-Value-Result (Simulated) is suitable when internal processing should not affect the original unless explicitly r_________.
Yes
Does Pass-by-Value support data protection?
No
Does Pass-by-Value allow data mutation?
original variables
Pass-by-Value Use Case: Protect o________ v___________
No
Does Pass-by-Reference support data protection?
Yes
Does Pass-by-Reference allow data mutation?
place
Pass-by-Reference Use Case: Modify caller’s data in p______
Yes
Does Pass-by-Result support data protection?
Yes (output only)
Does Pass-by-Result allow data mutation?
generated or computed
Pass-by-Result Use Case: Return g___________ or c___________ results
Yes (initially)
Does Pass-by-Value-Result support data protection?
Yes (reassigned)
Does Pass-by-Value-Result allow data mutation?
side-effects
Pass-by-Value-Result Use Case: Controlled s___ e_______
Call stack
When a subprogram is called, it must allocate memory to store its local variables, parameters, return address, and bookkeeping information. This allocation typically occurs in a region of memory called the c____ s______.
Call stack
is a system-managed data structure that tracks active subprogram calls during execution. activation record (or stack frame)
Stack Frame
Another term for activation record.
Parameter, Local Variable, Return Address
An activation record includes the following:
Parameters
These are passed to the subprogram
Local variables
These are declared inside the subprogram
Return address
(where to resume after the subprogram ends)
popped
When the subprogram completes, its activation record is p________ from the stack, and all memory associated with it is released.
Static Allocation and Stack-Dynamic Allocation
There are two (2) primary strategies for allocating local variables:
when and how
Static Allocation and Stack-Dynamic Allocation affect w___ and h____ long variables exist in memory and how subprograms can reuse or preserve data across multiple calls.
Stack-Dynamic Variables
These are local variables allocated at runtime when the subprogram is called.
execution
Stack-Dynamic Variables memory exists only during the e________ of that specific call. Once the subprogram returns, the variables are discarded, and subsequent calls will reinitialize them.
Stack-Dynamic Variables
This behavior is the default in Python and most modern programming languages.
recursion and concurrent
Stack-Dynamic Variables allows each call to a subprogram to have its own independent set of variables, which is essential for r_________ and c_________ function execution.
Memory Management
Automatic deallocation of local variables prevents memory leaks.
Recursion
Recursive functions rely on the stack to track each invocation's local state.
Data Isolation
Variables in different calls do not interfere with each other unless passed explicitly.
Performance
Stack allocation is fast due to the last-in, first-out (LIFO) nature of the call stack.