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 | |
|---|---|---|
| 1try: qty = int(text) except ValueError: qty = 0 | ASELECT COUNT(*) FROM students WHERE house = 'Red'; | |
| 2conn.commit() | BSaves changes to the database so the data is not lost after the program ends | |
| 3A reliable solution gives repeatable results: the same query on the same data gives the same answer every time | CThe change is never committed and errors are not handled, so data can be lost if the program ends or fails part way through. | |
| 4A reliable solution keeps asking until the input is valid, so bad input does not break it | DHandles invalid input so the program keeps running instead of crashing | |
| 5qty = int(input('Qty: ')) | EThere is no error handling. If the user types letters, int() raises a ValueError and the program crashes, so it is not reliable. | |
| 6cur.execute(sql) # no commit or error check | Fwhile not age.isdigit(): age = input('Age: ') |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
reliability — A reliable solution gives correct results every time and keeps working when input is bad or an error occurs, so no data is lost.try:
age = int(input("Age: "))
except ValueError:while not age.isdigit():
age = input("Enter digits: ")except sqlite3.Error:
conn.rollback()cur.execute(sql, (name, mark))
conn.commit()assert total(2, 3) == 5