What is decomposition in programming?
Decomposition divides a large problem into smaller tasks with clear purposes, often implemented as independently understandable and testable functions.
Study 9 Fundamental Programming Techniques with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is decomposition in programming?
Decomposition divides a large problem into smaller tasks with clear purposes, often implemented as independently understandable and testable functions.
What initial value does a sum accumulator use?
Initialize an addition accumulator to 0. Other common identities are 1 for products, 0 for counts, [] for collections, and {} for key-value data.
How should Python test whether an item exists?
Use the `in` operator when only membership matters. A set is especially useful for repeated membership tests because it stores unique values.
What is an early return in a linear search?
A linear search examines items from beginning to end and can return immediately when it finds a match, avoiding unnecessary work.
Which Python tool provides an index and value together?
Use `enumerate` when both the position and the value of each item are needed during iteration.
What does filtering do to a collection?
Filtering keeps items that satisfy a condition, so it can change how many items are present. A list comprehension is concise for a simple filter.
How does transformation differ from filtering?
Transformation converts each input item into a corresponding output item; unlike filtering, the number of items usually remains the same.
What is the usual order of a data-processing pipeline?
A common pipeline obtains data, validates or cleans it, filters unwanted items, transforms the remainder, and then reduces or summarizes it.
Which four categories improve test-case coverage?
Typical, boundary, invalid, and special cases. Together they test ordinary inputs, limits, incorrect data, and situations such as duplicates or missing values.
What does a Python `assert` test?
An `assert` compares an actual result with an expected result and raises an `AssertionError` when the comparison fails.
What is a systematic debugging workflow?
Reproduce the failure, read the traceback, reduce it to a minimal example, inspect values, form one hypothesis, make one focused change, and retest.
How do syntax errors differ from runtime exceptions?
A syntax error prevents valid program structure, while an exception occurs during execution of a syntactically valid program.