Search Header Logo

Python L34 Open File

Authored by Future Teacher

Computers

6th - 8th Grade

9 Questions

Used 1+ times

Python L34 Open File
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What does the following line do?

Reads the file and deletes it

Opens the file in write mode

Opens the file in read mode and assigns it to file

Creates a new file called data.txt

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Using with open(...) is a good practice because it automatically closes the file after use.

True

False

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What error will you get if you try to open a file that doesn’t exist in 'r' mode?

FileNotFoundError

PermissionError

IsADirectoryError

4.

FILL IN THE BLANK QUESTION

30 sec • 1 pt

To add new content to the end of an existing file without erasing it, use mode '____'.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method reads all lines from a file and stores them in a list?

.read()

.readlines()

.write()

.print()

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will be the output of this code if the file names.txt contains: Ali, Becky, Charles

1

2

3

0

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why is 'w' mode dangerous if you open an existing file?

The 'w' mode creates a backup of the existing file before writing.
The 'w' mode allows reading from the file without changes.

The 'w' mode overwrites the existing file, erasing all its content.

The 'w' mode appends new data to the existing 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?

Discover more resources for Computers