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_KEY = open('key.txt').read().strip() | Awith open('key.txt') as f: api_key = f.read().strip() | |
| 2key.txt | BA separate file that holds the API key and is listed in .gitignore so it is not committed to the repository | |
| 3Stop git from committing the file that holds your API key, so it is not pushed to a shared repository | CLoads the API key from a separate file so the secret is not written directly in the program code | |
| 4Read the key from a separate file when the program runs, instead of typing the secret into the code | Decho key.txt >> .gitignore | |
| 5API_KEY = 'a8f3k29xq71z' requests.get(url, params={'key': API_KEY}) | EThe API key is typed directly into the code, so anyone who sees or copies the code or repository can use it. Store it in a separate file that is not committed. | |
| 6git add key.txt git commit -m 'Add API key' | FThe file holding the API key is committed to the repository, so the secret is shared with everyone who can see it. Add the file to .gitignore instead. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
API key — A secret code that identifies your program to an API. Keep it in a separate file, out of the repository and shared code, because it is linked to your usage limits.from keys import KEYecho "keys.py" >> .gitignoreparams = {"key": KEY}limit = 100
if calls > limit:
print("Limit exceeded")KEY = open("key.txt").read().strip()