Python Files

Quiz
•
Computers
•
University
•
Medium
Elaine Cortez
Used 325+ times
FREE Resource
20 questions
Show all answers
1.
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(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
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.readline(8)) ?
I can't
I can
I can't write one song that's not about you
Error
3.
MULTIPLE SELECT QUESTION
30 sec • 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
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]) ?
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 list of strings?
.read()
.readline()
.readlines()
.read(all)
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Linux/PowerShell

Quiz
•
University
20 questions
Round-1 Technical Aptitude

Quiz
•
11th Grade - Professi...
15 questions
Examen Final Python

Quiz
•
University
20 questions
Python Prowess

Quiz
•
University
18 questions
CSE 102 Exam 3 Practice

Quiz
•
University
20 questions
Day 10 - ONLINE TEST - PL03 PYTHON PROGRAMMING

Quiz
•
University
20 questions
Python Functions and File Operations Quiz

Quiz
•
University
15 questions
Python

Quiz
•
University
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade