File Handling in Python -Revision test

File Handling in Python -Revision test

12th Grade

30 Qs

quiz-placeholder

Similar activities

Quize SK

Quize SK

12th Grade - University

25 Qs

PAS Mulok Komputer

PAS Mulok Komputer

12th Grade

25 Qs

komputer akuntansi

komputer akuntansi

12th Grade

25 Qs

Digital Technology Grade 9 Theory Test

Digital Technology Grade 9 Theory Test

9th - 12th Grade

25 Qs

แบบทดสอบเก็บคะแนน การสร้างเว็บไซด์

แบบทดสอบเก็บคะแนน การสร้างเว็บไซด์

11th - 12th Grade

25 Qs

DESAIN GRAFIS PERCETAKAN LEVEL 3

DESAIN GRAFIS PERCETAKAN LEVEL 3

12th Grade - University

25 Qs

PTS Desain Multimedia Interaktif

PTS Desain Multimedia Interaktif

12th Grade

25 Qs

TIK Icon

TIK Icon

12th Grade

25 Qs

File Handling in Python -Revision test

File Handling in Python -Revision test

Assessment

Quiz

Computers

12th Grade

Practice Problem

Hard

Created by

Naresh K Rana

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

A text file story.txt contains 500 lines. Which method is MOST memory-efficient for counting the number of lines?

len(f.readlines())

f.read().count("\n")

Iterating with for line in f and counting

f.readline() repeatedly storing in a list

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

A text file contains: Hello Python 123 Code What will f.read().split() return?

['Hello', 'Python', '123', 'Code']

['Hello Python', '123 Code']

['Hello Python\n123 Code']

['Hello', 'Python\n123', 'Code']

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which statement is TRUE about file reading in Python?

read() reads line by line

readline() reads the whole file

readlines() reads entire file into a list

read() returns list of strings

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

If a text file pointer is at the end after reading, which function resets it to the beginning?

f.restart()

f.flush()

f.seek(0)

f.reset()

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Consider: f=open("data.txt","r") print(f.readline(4)) If file contains "Python", output will be:

"Python"

"Pyth"

"Py"

Error

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

To count the number of words in a text file, the best approach is:

Count spaces

Use .split() on each line

Use .count(" ")

Count characters

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

A file is opened in "r+" mode. Which is TRUE?

Can read but not write

Can write but not read

Can read and write both

Only creates a new file

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?