File Handling in Python

File Handling in Python

12th Grade

15 Qs

quiz-placeholder

Similar activities

File Types

File Types

KG - Professional Development

12 Qs

Python Pliki

Python Pliki

12th Grade

10 Qs

File handling

File handling

12th Grade

10 Qs

Python Final Assessment

Python Final Assessment

4th - 12th Grade

10 Qs

Text File - Quiz

Text File - Quiz

12th Grade - University

10 Qs

CS - Internal Test1 [16-07-2021]

CS - Internal Test1 [16-07-2021]

12th Grade

20 Qs

File Types

File Types

12th Grade

18 Qs

CUET Level - II Computer Science(7/11/2023)

CUET Level - II Computer Science(7/11/2023)

12th Grade

15 Qs

File Handling in Python

File Handling in Python

Assessment

Quiz

Computers

12th Grade

Medium

Created by

Anita Mercy

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

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?