Recall & Review
beginner
What is a CSV file?
A CSV (Comma-Separated Values) file is a simple text file that stores tabular data. Each line is a row, and columns are separated by commas.
Click to reveal answer
beginner
Which Python module is commonly used to work with CSV files?
The built-in
csv module is used to read from and write to CSV files easily.Click to reveal answer
beginner
How do you read a CSV file using Python's csv module?
You open the file with
open(), then create a csv.reader object to loop through rows.Click to reveal answer
beginner
How do you write data to a CSV file in Python?
Open the file in write mode with
open(), create a csv.writer object, then use writer.writerow() to add rows.Click to reveal answer
beginner
Why should you use
with open() when working with files?Using
with open() automatically closes the file after the block ends, preventing file corruption or leaks.Click to reveal answer
What does each line in a CSV file represent?
✗ Incorrect
Each line in a CSV file corresponds to one row of data.
Which Python function is used to open a CSV file for reading?
✗ Incorrect
The built-in open() function is used to open files, including CSV files.
What method writes a single row to a CSV file using csv.writer?
✗ Incorrect
The writerow() method writes one row (a list of values) to the CSV file.
Why is it important to close a file after working with it?
✗ Incorrect
Closing a file saves changes and frees resources so other programs can use the file.
Which delimiter is most commonly used in CSV files?
✗ Incorrect
CSV stands for Comma-Separated Values, so commas separate the columns.
Explain how to read data from a CSV file in Python using the csv module.
Think about opening the file and then reading each line as a list.
You got /4 concepts.
Describe the steps to write multiple rows of data to a CSV file in Python.
Remember to open the file first, then write rows one by one or all at once.
You got /4 concepts.