Free Online Flashcard Deck

04 — Program Construction and Problem Solving Free Online FlashCards

Study 04 — Program Construction and Problem Solving with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What qualities characterize a well-constructed program?

Back

A well-constructed program produces correct results, handles invalid inputs safely, is readable, modular, testable, documented, and maintainable.

02
Front

What should a problem specification define?

Back

It defines the data received, the result required, valid assumptions, and what should happen when input is invalid.

03
Front

What is decomposition in program construction?

Back

Decomposition divides a large problem into smaller tasks that can be represented by algorithms, functions, or modules.

04
Front

What is an algorithm?

Back

An algorithm is a finite, ordered set of sufficiently precise steps for solving a problem.

05
Front

What is an invariant?

Back

An invariant is a fact that remains true during an algorithm. For an averaging loop, the running total equals the sum of scores processed so far.

06
Front

Why use meaningful names in code?

Back

Meaningful names communicate purpose, making code easier to read. For example, `average_score` is clearer than `x`.

07
Front

What does a function interface specify?

Back

A function’s interface describes its inputs, outputs, and error behavior. For `calculate_average`, the input is nonempty scores, the output is numeric, and an empty sequence raises `ValueError`.

08
Front

What do high cohesion and low coupling mean?

Back

High cohesion means a module’s elements support one main purpose. Low coupling means the module depends on as few details of other modules as possible.

09
Front

What information does a test case specify?

Back

A test case records the input, expected result, actual result, and whether the test passes or fails.

10
Front

What are boundary test cases?

Back

Boundary cases test values at or near limits, such as scores of `0` and `100` when the valid range is 0 through 100.

11
Front

What does a unit test check?

Back

A unit test checks a small unit of behavior, usually a function or method, and states one clear expectation.

12
Front

What is the purpose of regression testing?

Back

A regression test records behavior that must continue to work after changes. Existing tests should be rerun, and important discovered defects should receive new tests.