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 | |
|---|---|---|
| 1API | AAn endpoint: a specific address that a program sends a request to in order to use one feature or get one set of data | |
| 2https://api.example.com/weather | Bresponse = requests.get(url) | |
| 3A request and response: your program asks an API for data, and the API sends an answer back | CThe endpoint is not a full address. An endpoint is a specific URL, such as https://api.example.com/weather, so the request cannot reach the API. | |
| 4An API is a contract: it states what you must send and what you will get back, so both programs can rely on it | DGET /weather?city=Melbourne returns JSON | |
| 5An API lets you open the other program's source code and change how it works | EAn API does not give access to the other program's internal code. It only exposes defined requests and responses that you can use. | |
| 6requests.get("weather") # sends a request to the endpoint | FAn application programming interface: a defined set of requests and responses that lets one program use the features or data of another |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
API — An application programming interface: a defined set of requests and responses that lets one program use the features or data of another program.import requestsurl = "https://api.example.com/weather"
response = requests.get(url)response = requests.get(url)if response.status_code == 200:
print("Request succeeded")response = requests.get(url)
data = response.json()