File Handling in Python
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Medium
Anita Mercy
Used 93+ times
FREE Resource
Enhance your content in a minute
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Q1. Given the following file opened as song_file:
I can't write one song that's not about you
Can't drink without thinkin' about you
Is it too late to tell you that
Everything means nothing if I can't have you?
What is the result of
print(song_file.read(4)) ?
I ca
I can
I c
I can't write one song that's not about you
Can't drink without thinkin' about
I c
you
Is it too late to tell you that
Everything means nothing if I can't have you?
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the following file opened as song_file:
I can't write one song that's not about you
Can't drink without thinkin' about you
Is it too late to tell you that
Everything means nothing if I can't have you?
What is the result of
print(text_file.readlines()[1]) ?
I can't write one song that's not about you
Can't drink without thinkin' about you
I can't write one song that's not about you
Can't drink without thinkin' about
you
Is it too late to tell you that
Everything means nothing if I can't have you?
I
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to open the file file_in.txt for reading?
open('file_in.txt','a')
open('file_in.txt','r+')
open('file_in.txt', 'r')
open('file_in.txt','w')
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the best way to read an entire file into a single string?
.read()
.readline()
.readlines()
.read(all)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the best way to read an entire file into a list of strings?
.read()
.readline()
.readlines()
.read(all)
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the best way to read the first line of a file?
.read()
.readline()
.readlines()
.read(all)
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When reading text files, what are the hidden characters typically at the end of each line?
\n
»
#
@
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
10 questions
KTTX Tin 9-HKII
Quiz
•
9th - 12th Grade
20 questions
Quiz on Excel
Quiz
•
12th Grade
10 questions
Bitmap v Vector Images
Quiz
•
KG - University
18 questions
School Mangement System ICT 0417 IGCSE
Quiz
•
10th - 12th Grade
20 questions
Latihan Soal Administrasi Infrastruktur Jaringan XII TKJ
Quiz
•
10th - 12th Grade
20 questions
Pemrograman Dasar 3
Quiz
•
9th - 12th Grade
20 questions
PTS KELAS 9
Quiz
•
9th - 12th Grade
10 questions
HTML
Quiz
•
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
