
Exploring File Handling in Python

Quiz
•
Computers
•
12th Grade
•
Easy
Srividya Subramani
Used 1+ times
FREE Resource
16 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the 'open' function in Python?
To close a file after reading or writing.
To open a file and return a file object for reading or writing.
To create a new file in the current directory.
To delete a file from the system.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you read a text file line by line in Python?
Use 'open("filename.txt") as file: read(file)'
Use 'with open("filename.txt") as file: for line in file: print(line)'.
Use 'file.read_lines("filename.txt")'
Use 'open("filename.txt") and file.readlines()'
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What method would you use to write data to a text file?
Use file handling methods such as 'write()' or 'writelines()' after opening the file in write mode.
Use the 'append()' method to add data to the file.
Write data directly to the console instead of a file.
Use 'read()' method to write data to a file.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the difference between 'read()' and 'readlines()' methods.
The 'read()' method returns a single string, whereas 'readlines()' returns a list of strings.
Both 'read()' and 'readlines()' return the same type of data.
'read()' reads multiple lines at once, while 'readlines()' reads a single line.
'read()' is used for writing files, and 'readlines()' is for reading files.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you append data to an existing text file?
Delete the existing file and create a new one with the data.
Open the file in write mode and overwrite the data.
Open the file in append mode and write the data.
Open the file in read mode and write the data.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a CSV file and how is it different from a text file?
A CSV file is a database format that requires special software to read.
A CSV file is a structured text file that organizes data in rows and columns using commas as delimiters, while a text file is an unstructured file that can contain any text.
A CSV file is a type of image file used for graphics.
A CSV file is a binary file that cannot be opened in a text editor.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which Python module is commonly used for handling CSV files?
csv
json
txt
xml
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
TestOut CompTIA ITF Databases 20 Questions

Quiz
•
10th - 12th Grade
15 questions
File Handling in Python

Quiz
•
12th Grade
11 questions
File Management and Computer Literacy

Quiz
•
9th - 12th Grade
11 questions
2.2 Methods of Error Detection Cambridge IGCSE 0478

Quiz
•
10th Grade - University
15 questions
File Formats & File Naming

Quiz
•
KG - University
20 questions
Test Your Knowledge Google Drive

Quiz
•
9th Grade - University
16 questions
Device Configuration and Management- Domains 3 & 4

Quiz
•
9th - 12th Grade
20 questions
General Knowledge (ICT EDITION)

Quiz
•
10th Grade - University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade