
Exploring File Handling in Python
Authored by Srividya Subramani
Computers
12th Grade
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
Format File Gambar
Quiz
•
12th Grade
20 questions
Quiz ASJ
Quiz
•
12th Grade
20 questions
TIK 9 - Penggunaan Browser Untuk Akses Internet
Quiz
•
11th - 12th Grade
15 questions
หน่วยที่ 1 ความรู้พื้นฐานการจัดการ ข้อมูลขนาดใหญ่ (Big Data)
Quiz
•
9th - 12th Grade
17 questions
Quiz 01 Keamanan Jaringan
Quiz
•
12th Grade
15 questions
ONLINE Quiz - Computer Hardware Basics (COMSYS 1)
Quiz
•
12th Grade
14 questions
TCP/IP & other protocols [A Level]
Quiz
•
12th Grade
20 questions
Quiz
•
7th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade