Programming and reasoning

Start questions

Unofficial selected-topic practice.

Practice scope

Original English practice with worked guidance. Selected topics only. This is not a complete syllabus, official past-paper collection or predicted exam score. Check your own exam-board specification: these concepts are not certified against a particular board or exam year. Where a question shows a Cambridge 2027 reference, that is a conceptual placement only; no other exam board (such as Edexcel, AQA or OCR) is mapped, so do not assume this covers your board. Content here is written and checked with AI assistance; it has not been approved by an independent teacher or endorsed by any exam board.

160 original questions across 22 selected topic areas. No account or payment required to practise.

Cambridge International AS & A Level Computer Science (9618), examination year 2027: Conceptual alignment to official sources, not exam-board certification. Syllabus mapping and remaining coverage.

6 questions in this topic

Original questions with indicative worked guidance. Selected topics only.

All topics

Original practice in programming and reasoning; indicative answers for unofficial practice.

6 of 6 questions shown

Loading saved responses

Question 1Hide question3 indicative marks

A function receives integer x by value, assigns x=x+1 and returns nothing. The caller's variable n was 5. State n after the call and explain why.

Cambridge 2027: Direct conceptual match

Integer BYVAL changes only the local copy; matches the guide's default parameter rule without confusing Python object semantics.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Assignment changes the local parameter's storage. With no returned value assigned back and no shared reference to n, the local change cannot update the caller's integer variable.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

The stated integer pass-by-value model avoids object-mutation ambiguity.

Question 2Distinguish validation from verification for an entered date of birth, giving one example of each.3 indicative marks

Distinguish validation from verification for an entered date of birth, giving one example of each.

Cambridge 2027: Direct conceptual match

Calendar/range validation versus comparison with an input source directly distinguishes the specified integrity methods.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Rule checks reject impossible values, not every false value. Comparing to a trustworthy source addresses transcription accuracy, which a calendar-range test alone cannot establish.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

Passing validation does not prove factual correctness.

Question 3Trace this pseudocode (TO is inclusive): total <- 0; FOR i <- 1 TO 4; IF i MOD 2 = 0 THEN total <- total + i ELSE total <- total - 1; ENDIF; NEXT i. Give total after each iteration. Only one branch of the IF executes per iteration.3 indicative marks

Trace this pseudocode (TO is inclusive): total <- 0; FOR i <- 1 TO 4; IF i MOD 2 = 0 THEN total <- total + i ELSE total <- total - 1; ENDIF; NEXT i. Give total after each iteration. Only one branch of the IF executes per iteration.

Cambridge 2027: Partial conceptual match

Traces inclusive FOR plus IF/ELSE correctly, but the required construct-writing and other construct families remain untested.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Odd iterations subtract one; even iterations add the current index. Carry the updated total into the next iteration rather than recomputing from the original zero.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

Apply the ELSE only on odd iterations, not after every addition.

Question 4A recursive function F(n) returns 1 if n=0, otherwise returns n*F(n-1), for integer n>=0. Trace F(4), and explain the base case's role.3 indicative marks

A recursive function F(n) returns 1 if n=0, otherwise returns n*F(n-1), for integer n>=0. Trace F(4), and explain the base case's role.

Cambridge 2027: Direct conceptual match

Factorial call descent and base-case unwind directly trace the named recursion content; it duplicates some existing recursion practice rather than filling a new gap.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Each pending call waits for the smaller argument's result. F(0)=1 lets multiplication build 1, 2, 6 and 24 on return; without a reachable stopping case the descent would continue.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

Termination relies on the nonnegative-integer precondition and decreasing n.

Question 5A function accepts integer ages from 16 through 120 inclusive. Design a minimal boundary-focused test set that checks both acceptance boundaries and adjacent rejection, plus one distinct type-error case; state expected outcomes.4 indicative marks

A function accepts integer ages from 16 through 120 inclusive. Design a minimal boundary-focused test set that checks both acceptance boundaries and adjacent rejection, plus one distinct type-error case; state expected outcomes.

Cambridge 2027: Direct conceptual match

15/16/120/121 and a type-error case directly select abnormal/boundary data with expected outcomes.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Test just inside and just outside each permitted edge. A text case exercises parsing/type behaviour that numeric boundary tests cannot cover; expected outcomes make the tests checkable.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

Do not list only normal ages and call the set boundary testing.

Question 6Two tasks both execute read counter; add 1 locally; write counter. Starting at zero, show an interleaving ending at 1 rather than 2, and propose a synchronisation remedy with its scope.4 indicative marks

Two tasks both execute read counter; add 1 locally; write counter. Starting at zero, show an interleaving ending at 1 rather than 2, and propose a synchronisation remedy with its scope.

Cambridge 2027: Board-neutral enrichment

Lost-update interleavings and mutex scope are useful systems enrichment but not explicit process-scheduling or parameter-passing outcomes.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. The operation's apparent simplicity hides three steps. Correct synchronisation must make the entire state transition indivisible to competitors, so the second increment sees the first increment's result.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

A separate lock per task provides no mutual exclusion over shared state.

All AS & A Level subjects