Python File Handling Quiz

Python File Handling Quiz

10th Grade

25 Qs

quiz-placeholder

Similar activities

Analisis Data dengan Excel dan Google Colab

Analisis Data dengan Excel dan Google Colab

10th Grade - University

20 Qs

2.2 J277 File handling

2.2 J277 File handling

10th - 12th Grade

23 Qs

Computer Applications

Computer Applications

9th - 12th Grade

20 Qs

2.2 Programming techniques

2.2 Programming techniques

10th - 11th Grade

24 Qs

Python File Handling

Python File Handling

10th Grade

22 Qs

Python Middle Schooler

Python Middle Schooler

7th - 10th Grade

20 Qs

Computational Skills- PYP 4 B

Computational Skills- PYP 4 B

6th - 10th Grade

20 Qs

IGCSE ICT Ch 11

IGCSE ICT Ch 11

6th - 10th Grade

20 Qs

Python File Handling Quiz

Python File Handling Quiz

Assessment

Quiz

Computers

10th Grade

Medium

Created by

M Ellis

Used 4+ times

FREE Resource

25 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the key function for working with files in Python?

file()

open()

read()

write()

Answer explanation

The key function for working with files in Python is open(), which is used to open a file and return a file object for reading, writing, or both.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the 'r' mode do when opening a file in Python?

Reads and writes to the file

Appends to the file

Reads the file, error if the file does not exist

Creates the file

Answer explanation

The 'r' mode in Python opens a file for reading. It will throw an error if the file does not exist.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which mode should be used to open a file for appending in Python?

'r'

'w'

'a'

'x'

Answer explanation

The correct mode to open a file for appending in Python is 'a', which allows writing to the end of the file without truncating it.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens if you try to open a file in 'x' mode and the file already exists?

The file is overwritten

The file is read normally

An error is returned

The file is appended to

Answer explanation

Opening a file in 'x' mode will return an error if the file already exists, preventing accidental overwriting of existing files.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default mode when opening a file in Python?

Binary mode

Write mode

Append mode

Text mode

Answer explanation

The default mode when opening a file in Python is Text mode, which is used for reading and writing text files. It is denoted by 'r' or no mode specified.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which mode is represented by 'b' when handling files in Python?

Text mode

Binary mode

Append mode

Create mode

Answer explanation

The 'b' mode in Python represents Binary mode, which is used for handling files containing binary data like images or executable files.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax to open a file named "demofile.txt" for reading in Python?

f = open_file("demofile.txt")

f = open("demofile.txt", "r")

f = read("demofile.txt")

f = file("demofile.txt")

Answer explanation

The correct syntax to open a file named 'demofile.txt' for reading in Python is f = open('demofile.txt', 'r').

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?