Loading...
Choose representations from the meaning of the data, then apply operations with explicit language rules. A value that looks numeric is not necessarily a quantity to calculate with.
What you'll be able to do
An integer represents whole-number values, a real/float approximates a wider set of numerical values, and a Boolean represents true or false. Characters, strings and date/time values have different operations. A telephone identifier should usually be a string: leading zeroes and punctuation matter, while arithmetic on it is meaningless.
Arrays and records group values; a user-defined record can combine fields with different types. A pointer or reference identifies a dynamically created object rather than containing every field of that object inline. Not every language exposes raw memory addresses, so distinguish the model from the syntax.
Assignment associates a value with a variable; later assignment can change that association. A named constant expresses a fixed value or policy, improving readability and making changes easier to audit. Python capitalisation is a convention, whereas some languages enforce constant declarations.
Use meaningful names that describe quantities and units. A constant named MAX_ATTEMPTS explains a limit better than an unexplained 3. A declaration can specify a type in some languages; Python names instead refer to typed objects. Do not claim all languages require identical declaration syntax.
Real division and integer division answer different questions. In Python 3, / produces a division result while // uses floor division; % gives a remainder and ** exponentiation. For non-negative integers, quotient and remainder satisfy dividend=quotient×divisor+remainder. Negative-operand rules should be checked for the language used.
Rounding selects a nearby representable value; truncation discards a fractional part towards zero. Python round has tie rules, so do not assume every language rounds a half upwards. Convert numeric text deliberately and check whether floating approximation is suitable for exact decimal quantities.
MAX_ATTEMPTS = 3
items = 17
boxes = items // 5
left_over = items % 5
print(boxes, left_over)Scroll horizontally to see the full code or table.Attempt the task before opening its worked response. Record each change of state, explain the rule used, and check the result against the original requirements. Code examples labelled Python 3 use that language’s conventions; pseudocode states its own assumptions.
Common mistakes to avoid
Key takeaways
Test yourself
Answer a few questions, then review anything you missed.
Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.