Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1assert is_adult(18) == True | A| i | total | | 1 | 5 | | |
| 2import easy_grader | BA possible made-up library: check that it really exists before trusting the AI code that uses it | |
| 3Trace the AI code by hand with sample values, recording each variable as the lines run | CThe AI code fails the requirement at the boundary: age 18 should be accepted, so it should use >= instead of >. | |
| 4Test AI code with invalid data to see if it copes with bad input | Dcalculate_average("abc") | |
| 5# AI code ran with no errors, so it is correct. Ship it! | ERunning without errors does not prove the code is correct. It can still give wrong results, so it needs tracing and testing with your own data. | |
| 6if age > 18: # requirement: 18 or over | FA test with your own boundary value: checks the AI function gives the right result at exactly the cut-off age |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Verify AI-generated code — Read and trace AI code, then test it with your own boundary and invalid data, and check it meets the requirements. It can look right but be wrong or use made-up functions.assert grade(50) == "P"assert valid(-1) is Falsetry:
result = int("abc")
except ValueError:print(hasattr(str, "reverse"))mark = 100
print(0 <= mark <= 100)