Read the brief as a list of deliverables
Start by identifying the supplied input file, the required output file and the exact rules. In this project the input is results.csv, each accepted record produces one report row, and the file ends with a summary. If the instructions say “both scores at least 6”, compare both scores separately. A total of 12 is not sufficient on its own. Write the required output for one sample by hand so you know what to compare with the running program.
Use this decomposition before you write the whole program:
- Read each line and split it into fields. Check the field count before you use an index.
- Validate the identifier, the numeric format and the permitted numeric range. Work through these in that order. Only accepted rows go further.
- Call a helper that returns
PassorRetry. Check its result for(6, 6),(6, 5)and(5, 6)before involving files. - Write the report row and update the counters. Use a single write-mode file for the whole report, then add the summary after processing the last row.
- Reopen the output and compare it with the expected file. Check that a repeat run replaces the earlier report.
Plan the trace and test evidence
| Row | Decision | Valid count | Pass count | Output row |
|---|---|---|---|---|
A01,6,6 | Both reach 6 | 1 | 1 | A01,12,Pass |
B04,10,5 | Valid, second below 6 | 2 | 1 | B04,15,Retry |
C02,11,6 | Score out of range | 2 | 1 | None |
D03,0,0 | Valid, below threshold | 3 | 1 | D03,0,Retry |
,6,6 | Blank identifier | 3 | 1 | None |
The summary for this example is Valid: 3; Pass: 1. A typical case checks that records and totals are written. The cases at 0 and 10 check the range limits. The 6 and 5 pair checks the classification boundary. A missing field or malformed score should be ignored without a conversion or indexing crash. Test a file with no accepted records, because that exercises a path where the counters stay zero and only the summary is written.
Work like you would in an IDE
In the browser lab, give the first line as the number of raw records, followed by that many rows. The first block makes an input file from those values. Preserve that block for browser tests. Add your solution below it and use Run with my input to test a small example before checking the full set. If you get an error, find the last traceback line, then inspect the field list or types on that input. A temporary debug print can help you find the error. Remove it before comparing exact output.
For a local rehearsal, download the Python file and the original practice CSV. Put them in the same project folder. Remove only the browser setup block that asks for the row count and creates results.csv; the IDE run should read the supplied file instead. Run the file, open the actual report.csv, and compare it with your hand calculation. Save your edited Python file. Before using an official practice paper, read its instructions and keep its supplied files and names as directed. The browser is a place to learn the coding workflow. Paper 2 uses a local Python IDE and supplied digital files.
Review your submission under a time limit
Spend the first few minutes reading the full question, identifying which file you should edit and running the starter where appropriate. Fix the smallest part that lets you make progress. After a change, run a normal case and a case likely to expose that exact bug. Near the end, re-run an earlier case and check the requested filenames, output order, spelling and spaces. If you cannot complete every part, leave your working changes in the file. A partially working program with a correctly implemented requirement is worth reviewing against the mark guidance.
Practise a fresh change request
After completing the report, add a separate count of valid candidates whose total is 15 or higher. Keep Pass and Retry based on the original rule. Decide where to update the new counter and write a case that makes the new count and the pass count different. Add the number to the summary without changing the report rows. Test an empty file after running with a non-empty file to check that no old result remains.
If a timed rehearsal feels too large, complete validation and output first, then repeat the full task with a new input file. Keep the two results so you can see which step became quicker and which still needs practice.