
Python File Handling Quiz
Quiz
•
Computers
•
10th Grade
•
Practice Problem
•
Medium
M Ellis
Used 5+ times
FREE Resource
Enhance your content in a minute
25 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the key function for working with files in Python?
file()
open()
read()
write()
Answer explanation
The key function for working with files in Python is open(), which is used to open a file and return a file object for reading, writing, or both.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the 'r' mode do when opening a file in Python?
Reads and writes to the file
Appends to the file
Reads the file, error if the file does not exist
Creates the file
Answer explanation
The 'r' mode in Python opens a file for reading. It will throw an error if the file does not exist.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which mode should be used to open a file for appending in Python?
'r'
'w'
'a'
'x'
Answer explanation
The correct mode to open a file for appending in Python is 'a', which allows writing to the end of the file without truncating it.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if you try to open a file in 'x' mode and the file already exists?
The file is overwritten
The file is read normally
An error is returned
The file is appended to
Answer explanation
Opening a file in 'x' mode will return an error if the file already exists, preventing accidental overwriting of existing files.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the default mode when opening a file in Python?
Binary mode
Write mode
Append mode
Text mode
Answer explanation
The default mode when opening a file in Python is Text mode, which is used for reading and writing text files. It is denoted by 'r' or no mode specified.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which mode is represented by 'b' when handling files in Python?
Text mode
Binary mode
Append mode
Create mode
Answer explanation
The 'b' mode in Python represents Binary mode, which is used for handling files containing binary data like images or executable files.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct syntax to open a file named "demofile.txt" for reading in Python?
f = open_file("demofile.txt")
f = open("demofile.txt", "r")
f = read("demofile.txt")
f = file("demofile.txt")
Answer explanation
The correct syntax to open a file named 'demofile.txt' for reading in Python is f = open('demofile.txt', 'r').
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
Quiz SISKOM (Karakteristik Sistem Memori)
Quiz
•
10th Grade
20 questions
MSEXCEL QUIZ NO. 2
Quiz
•
10th Grade
22 questions
Programming Review
Quiz
•
9th - 12th Grade
20 questions
CSS Box Model
Quiz
•
10th Grade
21 questions
CSP Vocab Practice 2
Quiz
•
10th - 12th Grade
20 questions
Keyboarding Skills Review
Quiz
•
10th - 12th Grade
20 questions
Key Applications 2
Quiz
•
9th - 12th Grade
20 questions
Spreadsheet Overview (Basic)
Quiz
•
9th - 11th 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
