File Handling in Python

Quiz
•
Computers
•
12th Grade
•
Medium
Anita Mercy
Used 87+ times
FREE Resource
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
»
#
@
Create a free account and access millions of resources
Similar Resources on Wayground
13 questions
Binary files in Python

Quiz
•
12th Grade
18 questions
iGCSE Computer Science: Data Compression and Encryption

Quiz
•
9th - 12th Grade
20 questions
Exploring File Operations in Python

Quiz
•
12th Grade
20 questions
Text File Handling Set -1

Quiz
•
12th Grade
12 questions
KRIPTOGRAFI

Quiz
•
12th Grade
20 questions
Ulangan harian Informatika

Quiz
•
1st Grade - University
18 questions
Comandos y privilegios de linux

Quiz
•
12th Grade
10 questions
ASJ 12 TKJ - PERINTAH DASAR LINUX

Quiz
•
12th Grade
Popular Resources on Wayground
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
Discover more resources for Computers
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
62 questions
Spanish Speaking Countries, Capitals, and Locations

Quiz
•
9th - 12th Grade
20 questions
First Day of School

Quiz
•
6th - 12th Grade
6 questions
Maier - AMDM - Unit 1 - Quiz 1 - Estimation

Quiz
•
12th Grade
21 questions
Arithmetic Sequences

Quiz
•
9th - 12th Grade
21 questions
9th Grade English Diagnostic Quiz

Quiz
•
9th - 12th Grade
7 questions
Characteristics of Life

Interactive video
•
11th Grade - University