CBSE Class 12 Computer Science – File Handling in Python

Previous Chapter Next Chapter

Study Materials

12th

12th - Computer Science

File Handling in Python

Chapter Overview

This chapter introduces file handling in Python, essential for storing and processing data persistently. Students learn about types of files—text and binary, opening and closing files, reading/writing data using file methods, file modes, and using context managers. It empowers learners to develop programs that can handle data beyond runtime.

Important Keywords

  • File: A named location on disk to store data persistently.
  • Text File: Contains data in human-readable form (e.g., .txt).
  • Binary File: Contains data in encoded form (e.g., .dat, images).
  • open(): Opens a file and returns a file object.
  • read()/readline(): Used to read content from a file.
  • write()/writelines(): Writes data to file.
  • with statement: Used to open file using context manager and auto-close.

Detailed Notes

to view full chapter (File Handling in Python - Detailed Notes) resources.