Programming and Program Development
This domain tests control flow, functions, parameter passing, scope, testing, and the software development life cycle. Questions often ask you to trace short code or choose the test case that exposes a defect.
Core constructs
- Assignment stores a value; equality compares values. Short-circuit evaluation skips the right operand of AND/OR when the result is already determined.
- Pre-test loops check the condition before the body; post-test loops run the body at least once.
- Pass-by-value copies the argument; pass-by-reference lets the function modify the caller's variable. Objects and arrays often behave like references even when the language calls the mechanism by value.
- Local scope limits a variable to a block or function; global scope exposes it more widely and increases coupling.
Development and testing
Requirements, design, implementation, testing, and maintenance form the classic life cycle. Unit tests isolate functions; integration tests combine components; acceptance tests check user needs. Good test sets include boundary values, equivalence partitions, and invalid input.
Worked example
Consider def f(x): x = x + 1; return x, then a = 3; b = f(a). With pass-by-value, a remains 3 and b becomes 4 because the function modifies only its local copy. If the argument were a mutable list and the function appended to it, the caller would observe the change because both names refer to the same object. The reasoning depends on whether the value or the reference is copied.
Traps that cost marks
- Assuming a function changed a primitive argument after pass-by-value.
- Ignoring off-by-one errors at loop boundaries.
- Treating integer division as exact decimal division.
- Forgetting that short-circuit evaluation can skip side effects.
- Confusing unit tests with acceptance tests.