Proof Academy · Pearson Edexcel 1CP2
Paper 2 rehearsal
Read a starter file, make a targeted change and build a report from a new brief. Try the three original practice tasks in 40 minutes, then mark your work out of 16.
Use a repeatable exam routine
- Read the required behaviour, exact output and filename. Predict one test before touching the starter.
- Run the starter and find the first difference between expected and actual output. Trace the relevant variables.
- Make one focused change. Check a normal case and a case that would have exposed the original bug.
- Check empty or boundary inputs where relevant. Inspect the final output and save your edited Python file.
Use the sandbox for rehearsal. Edexcel Paper 2 uses Python 3 in a local IDE with supplied files. For your second attempt, download your scripts and the original practice stock file. Put the file beside your script and remove the browser setup block from the final task so it reads the saved CSV.
Task 1 · 8 minutes · 4 marks
Read and repair a starter file
A sports event counts entrants aged 12 to 16 inclusive. The first input is the number of entrants, followed by their ages. The starter should print the number of eligible entrants but reports only whether the last entrant qualifies. It also accepts 17. Repair both faults.
- Run the supplied code on 11, 12, 16 and 17, preceded by the count 4. Write down which comparisons are true.
- Keep the input order and print exactly one integer. Read the number of ages specified, even if some are outside the range.
Enter one value per line. Each input() reads the next line.
Ready to run.
Need a hint?
Initialise eligible before the loop so it survives each pass. Check the accepted upper limit against the brief.
Mark your solution
Award one mark for each requirement your code meets. Check the implementation as well as the output.
- Initialises the eligible count before the loop, including when the count of entrants is zero.
- Reads exactly the stated number of ages.
- Checks both inclusive limits correctly.
- Increments once per eligible age and prints one final count.
Task 2 · 12 minutes · 5 marks
Adapt an existing algorithm
A library's starter finds an exact label in a list. Change it so that labels and the target are compared without surrounding spaces and without regard to case. Keep the original first-match position and the no-match result.
- Read a count, then that many labels, then a target. Positions start at zero.
- The function must return the index of the first matching label. Return −1 if no label matches, including for an empty list.
- Check a list with two labels that become identical after cleaning. Also test a target that looks similar but is absent.
Enter one value per line. Each input() reads the next line.
Ready to run.
Need a hint?
Clean the target once before the loop. Clean each candidate when you compare it. Keep the indices of the original list.
Mark your solution
Award one mark for each requirement your code meets. Check the implementation as well as the output.
- Trims the target and each candidate.
- Compares without regard to case.
- Searches all eligible positions in original order and returns the first match.
- Returns −1 for a missing target, including on an empty list.
- The caller prints exactly the returned integer.
Task 3 · 20 minutes · 7 marks
Build a program from a new brief
A store wants a report of items that need reordering. The sandbox starter creates stock.csv from the supplied practice input. Read the file, validate rows, write restock.csv and show the finished report. Use the same processing code in your IDE with the downloadable stock file.
- The file has one code and one quantity per row, with no header. Reject rows with the wrong field count, an empty code or a quantity that is not decimal digits. Trim spaces around fields.
- A valid item needs reordering when its quantity is below 4. Write one code per line in input order, followed by Items: n, where n is the count of matching rows.
- Replace restock.csv on every run. Reopen it and print its contents. If no rows qualify, write only Items: 0.
Enter one value per line. Each input() reads the next line.
Ready to run.
Need a hint?
Open the input and output files before looping. Guard access to fields with len(fields) == 2. Test isdecimal() before int(). Write the summary after the loop.
Mark your solution
Award one mark for each requirement your code meets. Check the implementation as well as the output.
- Reads stock.csv and splits each row into fields.
- Checks field count before accessing positions.
- Trims the fields and rejects an empty code or invalid quantity.
- Uses a strict comparison with 4 after conversion.
- Writes the matching codes in input order.
- Accumulates the matching count and writes the summary once.
- Replaces and reopens the correct report file, including for empty input.