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') | AThe file name is not in quotes, so Python treats school.db as a variable name instead of a string. It should be 'school.db'. | |
| 2cur = conn.cursor() | BOpens the school.db database file (creating it if missing) and stores the connection in conn | |
| 3Before Python can use SQLite, the sqlite3 module must be brought into the program | CThe cursor is made from the connection, not the module. It should be conn.cursor(). | |
| 4When the program has finished with the database, the connection should be closed | Dimport sqlite3 | |
| 5conn = sqlite3.connect(school.db) | Econn.close() | |
| 6cur = sqlite3.cursor() | FCreates a cursor from the connection so the program can run SQL statements |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
sqlite3.connect() — Opens a SQLite database file from Python and returns a connection. Call conn.cursor() on it to get a cursor for running SQL, and conn.close() when finished.import sqlite3conn = sqlite3.connect("school.db")conn = sqlite3.connect("school.db")
cur = conn.cursor()cur.execute("CREATE TABLE pet(id INTEGER)")cur = conn.cursor()
conn.close()