Show model answer and explanation
120
30 × 4 = 120.
Class 6 · English Medium · Cambridge · ICT
Build a small program from requirements and improve it using tests.
Shared cross-level core and stretch unit. Start with the core questions, then use the stretch example for deeper work. The same unit is available in related class and board pathways; it is not a full grade-specific or examination-specification course. A teacher should select the appropriate depth and further topics.
Separate the required behaviour from the implementation. A function can accept inputs and return an output; validation rejects unsupported input. Tests need independently determined expected results. A project also needs readable naming and a record of known limits. Never paste unknown code or secrets into a live console.
Requirement: ticket_total(n) returns 30*n for whole-number n from 0 to 10; other inputs are rejected. Tests include 0→0, 3→90, 10→300 and 11→rejected. This is pseudocode, not a running payment system.
A test double can stand in for an external service so a local test does not send real messages or take payment. Integration tests separately check whether the real components communicate correctly in an authorised test environment.
Show your working on paper and enter your answer here. If it does not match, compare the model and try again.
120
30 × 4 = 120.
rejected
It exceeds the allowed maximum 10.
0
Zero tickets cost zero in this model.
Write in your own words. A guardian or teacher should review this response.
IF n < 0 THEN return an error; otherwise continue validation.
Do not calculate a negative bill.
Write in your own words. A guardian or teacher should review this response.
That would repeat the same bug instead of checking the requirement independently.
Explain independence of the check.
no
A test double replaces the real service.
Write in your own words. A guardian or teacher should review this response.
Unit: check ticket_total(3)=90 locally. Integration: in an authorised sandbox, check the booking passes that amount to a test gateway.
Keep test environment and real transactions distinct.
Create a local quiz counter or its complete paper trace.
Keep your work on paper or in a local file. This page does not upload it or automatically grade the project.
Teacher-led lessons, schedules and prices for this outline are upcoming. You can use any starter practice above now without booking.
Solo practice works without an account. Sign in to save a practice record to your learner profile.
Exact lesson links and related activities are labelled separately. Return-to-course links retain your selected learning path.