Python L34 Open File

Python L34 Open File

6th - 8th Grade

9 Qs

quiz-placeholder

Similar activities

Bab 3 Ekstensi File

Bab 3 Ekstensi File

7th Grade

10 Qs

2nd term ict

2nd term ict

6th Grade

10 Qs

Python file handling

Python file handling

8th - 11th Grade

10 Qs

Kompozer

Kompozer

8th Grade

10 Qs

Test de inițiere

Test de inițiere

7th Grade

10 Qs

File Extensions

File Extensions

6th - 8th Grade

14 Qs

file extensions

file extensions

5th - 8th Grade

10 Qs

ICT Computing Essentials - Lesson 3: Computer Software

ICT Computing Essentials - Lesson 3: Computer Software

6th - 8th Grade

10 Qs

Python L34 Open File

Python L34 Open File

Assessment

Quiz

Computers

6th - 8th Grade

Medium

Created by

Future Teacher

Used 1+ times

FREE Resource

9 questions

Show all answers

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.

8.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The .read() method returns a list of lines from the file.

True

False

9.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will this code do?

Append text to hello.txt

Read the content of hello.txt

Overwrite hello.txt and write "Hi there!\n"

Do nothing unless the file already exists