You scored 100 out of 100 in the school quiz. Why does the checker say 'Reject'?
You get full marks in your school quiz, but the score checker says reject. Another version of the checker can't even start. Both versions have an error. What could make them fail in such different ways?
Assume the score is an integer. Predict what the checker should print for each test. Forty-two is typical, so it should pass. Zero and one hundred should pass because both ends are included. One hundred and one should be rejected because it is above the maximum.
Try one hundred in version A. Look at the end of line two. Python expects a colon after the if condition, before the indented instructions. The colon is missing, so Python reports a syntax error before it can print either result.
You're asked to identify the error in version A. Look at the if line again. Which option gives both the type of error and its exact location? Pick one.
Version B starts with the same score, one hundred. This time line two has its colon. Follow the run: Python reads the score, evaluates the condition, then goes to the else branch and prints reject. Compare that with the expected accept.
At one hundred, the lower comparison is true. The upper comparison is false because one hundred is not less than itself, so the checker prints Reject. That's a logic error on line two. Change the upper comparison to less than or equal to. Both comparisons are now true, so it prints Accept.
A different quiz accepts scores up to and including fifty. Its program runs, but line two uses less than fifty and rejects a score of fifty. Pick the answer that identifies the error.
Testing means comparing what happens with what you expected. For every score, version A reports a syntax error before it can accept or reject anything. Version B only disagrees with the prediction at one hundred. Run all four tests again after the fix. Now all four results match.
You might call any wrong output a syntax error and blame the Reject message. Here, Python understands the code, so the wrong decision is a logic error. If the exam asks you to identify it, pinpoint the upper comparison on line two: less than one hundred excludes the legal maximum.
If you're asked to write a routine to authenticate a user, start by asking for the username and password. Use and to check that both match the expected values for the same account. Grant access if both match. Otherwise, deny it. These fixed values are just for practice.