Programming Easy

Python: File I/O

File input and output is one of the most practical skills in Python — reading configuration files, writing logs, processing CSVs, and more. This quiz covers the essentials of Python's file handling, from opening modes to context managers.

Questions test knowledge of open() modes (r, w, a, rb, wb), the with statement for safe file handling, reading methods (read, readline, readlines), writing, and working with file paths using the os and pathlib modules.

Clean file handling is also about avoiding common mistakes — unclosed files, wrong encoding, incorrect paths. This quiz covers the patterns that prevent those bugs.

Start quiz → Opens in a new tab on Cletica
Sample questions3 of 10 shown
Q1
What file mode opens a file for writing and creates it if it doesn't exist, overwriting if it does?
Q2
Why is the 'with open()' statement preferred over just 'open()'?
Q3
What does file.readlines() return?
Answer all 10 questions on Cletica →

What This Quiz Covers

Cletica

Want to create your own quiz?

Build surveys and quizzes, share with anyone, collect responses — free to start.

Try Cletica for free →