Python Reading files

Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Susan O'Connell
Used 55+ times
FREE Resource
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 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(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 you
Is it too late to tell you that
Everything means nothing if I can't have you?
2.
MULTIPLE CHOICE QUESTION
1 min • 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.readline(8)) ?
I can't
I can
I can't write one song that's not about you
Error
3.
MULTIPLE SELECT QUESTION
1 min • 1 pt
Given a text file opened as file_in, which of the following will print the entire file? (Select ALL that apply.)
print(file_in.read())
print(file_in)
lines = file_in.readlines()
for line in lines:
print(line)
lines = file_in.readlines()
for i in range(len(lines)):
print(lines)
for line in file_in:
print(line)
4.
MULTIPLE CHOICE QUESTION
1 min • 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]) ?
Can't drink without thinkin' about you
I can't write one song that's not 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
5.
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', 'r')
open('file_in.txt','r+')
open('file_in.txt','w')
open('file_in.txt','a')
6.
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)
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the best way to read an entire file into a tuple?
.read()
.readline()
.readlines()
.read(all)
8.
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)
9.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When reading text files, what are the hidden characters typically at the end of each line?
\n
#
@
»
Similar Resources on Wayground
7 questions
File Handling with Python

Quiz
•
12th Grade - University
10 questions
File Handling

Quiz
•
12th Grade
13 questions
Binary files in Python

Quiz
•
12th Grade
10 questions
Python file

Quiz
•
1st - 10th Grade
10 questions
Prog. no Des. de Sistemas - Escrita e leitura de arquivos

Quiz
•
12th Grade
10 questions
Bitmap v Vector Images

Quiz
•
KG - University
10 questions
AP Computer Science Principles Unit 3 Review

Quiz
•
9th - 12th Grade
12 questions
Photoshop Basics

Quiz
•
11th Grade
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade
Discover more resources for Computers
50 questions
Trivia 7/25

Quiz
•
12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade
6 questions
RL.10.1 Cite Evidence

Quiz
•
10th Grade
10 questions
Characteristics of Life

Quiz
•
9th - 10th Grade
14 questions
Algebra 1 SOL Review #1

Quiz
•
9th Grade