Study guides
Programming Fundamentals
2 guides for this subject — how to prepare, what to practise, and how to know it has gone in.
A practice question
Choose an answer and it is marked, with the explanation. From Programming Fundamentals Practice Questions: 10 Worked Examples.
What does this code print? print(17 // 5, 17 % 5)
The correct answer is 3 2. Floor division gives the integer quotient: 17 // 5 is 3. The remainder operator gives what is left over: 17 % 5 is 2, since 5 × 3 + 2 = 17. The strongest distractor is 3 3; it incorrectly treats the remainder as the quotient.
A spoken answer, marked
An examiner's question, answered out loud and marked criterion by criterion. From Programming Fundamentals Viva Questions: A Practice Guide.
Examiner
In this pseudocode, what is the value of x after the call, and why? Explain what would need to change for the caller to receive the updated value. function change(n) n = n + 1 x = 4 change(x)
Correctly says x remains 4 in the stated pseudocode, but initially calls n a reference without a language rule to support that claim.
ImproveState the behaviour of this pseudocode first; qualify any pass-by-reference comparison by naming the language or convention.
Explains that n is assigned 5 inside the function, but does not clearly separate the local name from x.
ImproveSay that the function’s parameter n receives the argument value and the assignment changes n, not the caller’s x.
Uses the supplied values, which makes the result checkable.
ImproveAdd one contrast: return n and assign the result to x, if the pseudocode language supports that form.
Recognises that behaviour can differ between languages, but does not explain what assumption the answer uses.
ImproveIdentify the snippet as value-copying pseudocode and say that object mutation and language-specific reference rules are separate cases.
A strong answerIn this pseudocode, x is still 4 after the call. The argument’s value is used to initialise the parameter n, and the assignment n = n + 1 changes that parameter to 5. It does not assign a new value to the caller’s variable x. To update x in this example, the function could return 5 and the caller could assign that result to x. Actual parameter and reference behaviour depends on the language, so I would name the language before making a broader claim.
Yours are written from your own notes, and the free plan needs no payment details.
Guides
- Programming Fundamentals Practice Questions: 10 Worked ExamplesPractise ten programming fundamentals questions with worked explanations on Python tracing, functions, lists, loops, algorithms and debugging.
- Programming Fundamentals Viva Questions: A Practice GuidePractise programming fundamentals viva questions with worked answers on functions, loops and recursion, plus a repeatable method for improving aloud.
Studying programming fundamentals? Build your programming fundamentals board from your own notes — the cards, papers and lectures are written from it. Free plan: 20 cards, a paper, a lecture and a viva to try.
Start on MySummaries