1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
Before reading a CSV file, you must import the module that contains the CSV reader. Code the line that imports the module. | import csv | ^ *import csv *$ | |
The module you've imported is csv. You're calling the module's function named reader. The handle for the file you're reading is f. Complete the function call. | contents_of_csv_file = ______________________ | csv.reader(f) | ^ *csv\.reader\(f\) *$ |
Using the shorthand form, open products.csv for reading. The file handle is prods | with open("products.csv") as prods: | with `open`(`"`products.csv`"`) `as `prods`: | |
Complete the line to call the reader function in the csv module. The file handle is prods | product_list = _________________ | csv.reader(prods) | csv.reader(prods) |
Call the reader function in the csv module. Make up the file handle and variable. | content = csv.reader(f) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = csv\.reader\([a-zA-Z_][a-zA-Z0-9_]*\) *$ | |
Open a CSV file for reading using shorthand. Then read it. Make everything up. Remember to indent the second line. | with open("students.csv") as f: student_list = csv.reader(f) |
^ *with open\(•.+\.csv•\) as ([a-zA-Z_][a-zA-Z0-9_]*):\n [a-zA-Z_][a-zA-Z0-9_]* = csv\.reader\(\1\) *$ | |
Call csv.reader(f). Make up the name of the variable. | read_it = csv.reader(f) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = csv\.reader\(f\) *$ | |
Call reader. Make everything up. | x = csv.reader(f) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = csv\.reader\([a-zA-Z_][a-zA-Z0-9_]*\) *$ | |
Open a CSV file for reading using shorthand. Then read it. Make everything up. | with open("potions.csv") as file_to_read: read_file = csv.reader(file_to_read) |
^ *with open\(•.+\.csv•\) as ([a-zA-Z_][a-zA-Z0-9_]*):\n [a-zA-Z_][a-zA-Z0-9_]* = csv\.reader\(\1\) *$ | |
|
import csv with open("potions.csv") as file_to_read: read_file = csv.reader(file_to_read) |
^ *import csv\nwith open\(•.+\.csv•\) as ([a-zA-Z_][a-zA-Z0-9_]*):\n [a-zA-Z_][a-zA-Z0-9_]* = csv\.reader\(\1\) *$ | |
|
|||