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 | |
|---|---|---|
| 1conn = sqlite3.connect("school.db") | Aconnect() belongs to the sqlite3 library, so it needs the sqlite3. prefix. It should be sqlite3.connect("school.db"), otherwise Python raises a NameError. | |
| 2cur = conn.cursor() | Bimport sqlite3 | |
| 3Before a Python program can use SQLite, the sqlite3 library must be brought in with an import. | COpens the database file school.db (creating it if it is missing) and returns a connection object stored in conn. | |
| 4When the program has finished with the database, the connection should be closed to end it. | DMakes a cursor from the connection, which is the object used to run SQL commands on the database. | |
| 5conn = connect("school.db") | EA cursor is made from the connection, not from the sqlite3 module. It should be conn.cursor(), using the connection returned by connect(). | |
| 6cur = sqlite3.cursor() | Fconn.close() |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
conn = sqlite3.connect("school.db") — Opens the SQLite database file school.db (creating it if missing) and returns a connection. Then conn.cursor() makes a cursor to run SQL, and conn.close() ends the connection.import sqlite3conn = sqlite3.connect("school.db")import sqlite3
conn = sqlite3.connect("school.db")conn = sqlite3.connect("school.db")
cur = conn.cursor()cur = conn.cursor()
conn.close()