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 | |
|---|---|---|
| 1except requests.exceptions.ConnectionError: | ANo try/except around json.loads, so malformed JSON or a missing key crashes the prototype. A reliability test with broken data would fail. | |
| 2except json.JSONDecodeError: | BHandles the no connection case so the prototype shows a message instead of crashing when the API is offline | |
| 3Reliability test for a missing file: the prototype must not crash when the data file does not exist | CReliability needs repeated runs and awkward conditions such as offline, empty or malformed data. One successful run does not prove consistent results. | |
| 4Reliability test for slow sources: the prototype stops waiting after a set time instead of freezing | DCatches malformed JSON so the prototype copes when the source sends broken data | |
| 5data = json.loads(text) print(data["name"]) | Erequests.get(url, timeout=5) | |
| 6Test run 1 only: works, so the prototype is reliable | Fexcept FileNotFoundError: |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
reliability testing — Checking a prototype keeps working when the data source is offline, missing, empty, slow or sends malformed data, and gives consistent results on repeated runs.try:
r = requests.get(url, timeout=5)
except requests.ConnectionError:try:
f = open('data.csv')
except FileNotFoundError:try:
data = json.loads(text)
except json.JSONDecodeError:if len(rows) == 0:
print("No data returned")for run in range(3):
print(get_total())