Question 1Hide question5 indicative marks
Supplied fictional sensor inputs are [0, 10, 100]. A draft mean_valid uses '0 < value < 100' and divides total by count with no empty check. Contract: accept integer readings from 0 to 100 inclusive (reject booleans), ignore all other entries, and return None if none qualify. Trace the corrected total/count after every input and give the return. Supply runnable Python 3 code and tests for boundaries, normal, abnormal, empty and all-invalid inputs; explain which tests expose each draft fault and what an honest execution-evidence record would contain. This is conceptual practice, not candidate Paper 4 execution. Give a connected worked response with calculations, justified conclusions and limitations. All datasets are original fictional practice, not official experiment results. Written/supplied-data work only; any actual laboratory or field activity requires teacher approval, risk assessment and supervision. No human trials. Primary reading: https://www.cambridgeinternational.org/Images/721397-2027-2029-syllabus.pdf
Cambridge 2027: Partial conceptual match
Runnable console model, trace and test evidence: selected written evidence only. Published Python block executed by regression test with additional independent oracle cases and a boundary-mutant check; learner execution explicitly unproven. Science practical-N and computing rN rows are internal identifiers, not official numbered leaf syllabus codes. Aggregate rows are only partially supported. Actual apparatus use, candidate coding execution and practical attainment are not demonstrated here. Independent teacher review remains required.
- 9618: 11.3 Structured Programming / Candidates should be able to / objective row 4: Define and use functions
- 9618: 12.3 Program Testing and Maintenance / Candidates should be able to / objective row 3: Correct detected errors
- 9618: 12.3 Program Testing and Maintenance / Candidates should be able to / objective row 5: Test strategy and test plan contents
- 9618: 12.3 Program Testing and Maintenance / Candidates should be able to / objective row 6: Choose normal, abnormal and boundary test data
AI-assisted placement. Independent teacher approval pending.
Show indicative guidance
Worked guidance
- For 0 the total remains zero but count increases to one; 10 gives total 10/count 2; 100 gives total 110/count 3. The draft would accept only 10 and return 10, so a normal middle-value test alone misses its boundary fault. Empty and all-invalid cases expose its unguarded division.
import unittest def mean_valid(values): total = 0 count = 0 for value in values: if type(value) is int and 0 <= value <= 100: total += value count += 1 return total / count if count else None class MeanTests(unittest.TestCase): def test_normal(self): self.assertEqual(mean_valid([20, 40]), 30) def test_boundaries(self): self.assertEqual(mean_valid([0, 100]), 50) self.assertAlmostEqual(mean_valid([0, 10, 100]), 110 / 3) def test_abnormal(self): self.assertIsNone(mean_valid([-1, 101, True, 3.5, '5', None])) def test_empty(self): self.assertIsNone(mean_valid([])) if __name__ == '__main__': unittest.main()- A plausible alternative is a filtered list plus sum/len with the same explicit type and empty rules, trading extra storage for brevity. Capture the exact code revision, environment, test inputs, expected/actual returns and pass/fail output, then document any correction and regression rerun. Do not fabricate a screenshot or say a learner ran this because the author tested it. A small passing suite does not prove correctness for arbitrary iterables or establish practical assessment competence.
Self-marking points
Tick what your working earned. The count is your own self-assessment.
Self-assessed: not counted yet. This question is worth 5 marks.
Examiner tip
Indicative original worked practice, independent teacher approval pending. Explain assumptions and alternatives; do not equate a correct written answer with observed practical performance.