Free WACE Computer Science Flashcard Review
Review 20 public cards with spaced repetition. Flip a card, then grade your recall. Cards you miss return today. Your schedule stays in this browser.
Loading your review schedule…
Browse the free cards
Sequence (control structure)
Statements are executed one after another in the order they are written, with no branching or repetition.
Selection (control structure)
A condition decides which path runs: one-way (IF ... END IF), two-way (IF ... ELSE) or multi-way (ELSE IF chains or CASE).
Pre-test loop vs post-test loop
A pre-test loop (WHILE) checks its condition before the body, so it may run zero times; a post-test loop (REPEAT ... UNTIL) checks after the body, so it always runs at least once.
Fixed (count-controlled) loop
A FOR loop that repeats a known number of times, e.g. FOR i = 1 TO 10; use it when the number of iterations is known before the loop starts.
When should a CASE statement not be used?
When the decision depends on ranges of values (e.g. marks 50 to 64); the support booklet says CASE should test single values, so use IF ... ELSE IF for ranges.
Integer division (DIV, //) and modulus (MOD, %)
// gives the whole-number quotient and % gives the remainder: 7 // 2 = 3 and 7 % 2 = 1. A common use is x % 2 == 0 to test for an even number.
Python value of 2 + 3 * 4 ** 2
50. Exponentiation is done first (4 ** 2 = 16), then multiplication (3 * 16 = 48), then addition (2 + 48).
Order of precedence of logical operators
NOT is evaluated first, then AND, then OR. Relational operators (<, ==, etc.) are evaluated before any of the logical operators.
Value of True or False and False in Python
True. AND binds more tightly than OR, so it is True or (False and False) = True or False = True.
De Morgan's law for NOT (A OR B)
NOT (A OR B) is equivalent to (NOT A) AND (NOT B); likewise NOT (A AND B) is equivalent to (NOT A) OR (NOT B).
Boolean expression that is TRUE only for ages 13 to 17 inclusive
age >= 13 AND age <= 17. Using OR here would be TRUE for every age, a classic logic error.
How a truth table proves two Boolean expressions are equivalent
List every combination of input values (2^n rows for n inputs), evaluate both expressions in each row; they are equivalent only if their results match in every row.
Parameter vs argument
A parameter is the variable named in the function definition (def area(w, h)); an argument is the actual value passed in the call (area(4, 5)).
Local variable
A variable created inside a function; it exists only while the function runs and cannot be accessed from outside it.
Global variable
A variable declared outside all functions and accessible throughout the program; good practice keeps globals to a minimum because any module can change them unexpectedly.
Pass by value
The function receives a copy of the argument's value, so changes inside the function do not affect the original variable.
Pass by reference
The function receives a reference to the original data, so changes inside the function alter the caller's data, e.g. modifying a Python list passed into a function.
Why should a function return a value instead of changing a reference parameter?
Returning one value or data structure makes the function's effect explicit and testable, avoids hidden side effects, and matches the support booklet's advice to avoid reference parameters where possible.
One-dimensional array
An ordered collection of elements accessed by a single index starting at 0, e.g. scores[0] is the first element.
In grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]], what is grid[1][2]?
6. The first index selects row 1 ([4, 5, 6]) and the second index selects column 2 within that row.