File i/o

File i/o

10th Grade

20 Qs

quiz-placeholder

Similar activities

20.2 File Processing and Exception Handling Cambridge iA 9618

20.2 File Processing and Exception Handling Cambridge iA 9618

12th Grade

20 Qs

File Handling in Python, Serialization in Python

File Handling in Python, Serialization in Python

University

15 Qs

File Methods in Python

File Methods in Python

12th Grade

20 Qs

PYTHON PROGRAMMING FILES Q7

PYTHON PROGRAMMING FILES Q7

University

20 Qs

Test files - Python

Test files - Python

University

20 Qs

Class 12 revision for PT1

Class 12 revision for PT1

12th Grade

20 Qs

Text File Handling Set -1

Text File Handling Set -1

12th Grade

20 Qs

linux commands

linux commands

University

20 Qs

File i/o

File i/o

Assessment

Quiz

Computers

10th Grade

Medium

Created by

Ержан Ауезов

Used 14+ 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 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

4.

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')

5.

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)

6.

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)

7.

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)

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?