Your school race program runs without errors. Will it let a runner use lane 8?
At a school race in Leeds, a runner enters the correct access code and picks lane eight. Your program runs without an error, but it rejects the entry. How would you show which part needs fixing?
Start with your race design. The inputs are an access code and a whole-number lane. Check the demo code, RUN, first. If it doesn't match, report Denied. If it matches, check the lane. Report Accepted for lanes one to eight, including both ends, and Invalid lane otherwise.
Fill in the expected results from the brief before you run the code. With the correct code, try zero, one, eight and nine. Those inputs sit at or just outside the lane limits. Then try the wrong code with a valid lane to test authentication separately.
Before you look at the Python, suppose a runner enters the correct code and chooses lane nine. What should you write in the expected result column? Pick an answer based on the brief.
In Python three, write the lane function first. Then write the entry function: deny wrong codes and use the lane check to choose Accepted or Invalid lane. The final lines read the code and whole-number lane and print the result. Run all five pairs and record what the program actually prints.
For RUN and lane eight, you expected Accepted. Trace that input to see why the first run disagreed. The code matches. Eight is at least one, so the lower check passes. Eight is not less than eight, so the upper check fails. The program prints Invalid lane.
A smaller race uses the same entry function, but its brief allows lanes one to six inclusive. The lane function checks for at least one and less than six. If you enter the correct code and lane six, what will the program actually print? Pick an answer.
Look at the return line in the lane function. Less than eight excludes eight, even though the brief includes it. Change the upper comparison to less than or equal to eight. Leave the lower comparison and the rest of the program unchanged.
Save the repair and run the complete program once for each input pair. Record the retest outputs. Zero is still invalid, one is still accepted, and eight changes from Invalid lane to Accepted. Nine is still invalid, and GO is still denied. Each retest output matches its expected result.
If asked to explain how your solution meets the brief, cite test evidence. For RUN, lane eight, you expected Accepted and got Accepted, so lane eight is included. For GO, lane four, you expected Denied and got Denied, so the wrong code is rejected. Running without errors doesn't establish either result.