Class 12 Computer Science File Handling in Python PYQ, free to download as a 89-page PDF with 71 solved questions: 24 from the 2023 to 2026 board papers and 47 from CBSE's official sample papers. File Handling is part of Unit 1, Computational Thinking and Programming - 2, the largest unit of the Class 12 Computer Science (083) theory paper.
The questions keep returning to text-file programs (30 questions), CSV files (19), binary files and pickle (18), output prediction on a given file (12), file modes (10) and seek() or tell() (8).
On this page you get:
- 71 questions with a worked solution each: 38 MCQs, 13 short answers and 20 programs or case studies
- An Answer Key that lists all 37 MCQs with options at a glance
- Question counts by topic, so you know whether to start with text files, CSV or binary files
- A marks-wise table of questions (1, 3, 4 and 5 mark)
- The common mistakes students make, such as using seek(0,-1) when the reference point can only be 0, 1 or 2, and a short FAQ
File Handling in Python Weightage in the Class 12 Computer Science Paper
CBSE does not print a mark figure for File Handling alone. The Class 12 Computer Science (083) theory paper is out of 70 marks, and File Handling belongs to Unit 1, Computational Thinking and Programming - 2, which carries about 40 of them. That is a unit-level figure as reported by prep sites, so check the current year's document on cbseacademic.nic.in. Within the unit, File Handling usually supplies a 1-mark MCQ or two, a 3-mark text-file function and a 5-mark question on binary or CSV files. The unit marks are as reported by prep sites and the published syllabus summaries, and we could not confirm them on a CBSE document, so treat them as unofficial.
The set groups questions by the marks they carry. Of the 71 questions, 24 come from the 2023, 2024, 2025 and 2026 board papers and 47 from sample papers.
| Marks per Question | Questions in the Set |
|---|---|
| 1 mark (MCQ) | 38 |
| 3 marks | 13 |
| 4 marks (case study) | 9 |
| 5 marks | 11 |
File Handling in Python Questions by Topic
Text files carry the most weight: 30 of the 71 questions use a file such as Space.txt, STORY.TXT or LINES.TXT. The 3-mark group is almost entirely this kind of function, for example counting the digits in a file, displaying the lines that contain the word 'vote', or printing words that start and end with a vowel.
CSV files appear in 19 questions. The longer ones are case studies built around files such as Peripheral.csv, Result.csv or Rentals.csv, where you write one function to add a record and another to read, search or count rows with the csv module. Binary files and pickle come up in 18 questions, mostly a record list stored in a file like Cust_file.dat or EMP.DAT, with a function to write, search or update a record.
12 questions show a small file and ask for the output of a read(), readline() or readlines() call. File modes are tested in 10 questions, including 'rb' for read-only binary access and the difference between r+ and w+. seek() and tell() feature in 8, and pickle.dump() or load() in 7. The counts come from keyword matches over the question text, so a question that names two file types is counted under both.
Source: Magnet Brains
How to Approach the Set
Begin with the 38 MCQs. Many are quick checks on modes, methods and the pickle module, so a short revision of open() modes pays off here. Then take the 3-mark functions: open the file, loop over lines or words, test one condition and print. For the 4-mark and 5-mark questions, practise the three standard patterns on paper, appending a record, searching for one, and updating one in a binary file, because the same skeletons repeat with new field names. Run each program on a sample file before you read the solution.
Common Mistakes in File Handling in Python Questions
- Writing F.seek(0,-1). The reference point can only be 0, 1 or 2, so this raises a ValueError.
- Mixing up dump() and load(). dump() writes an object to a binary file, load() reads it back.
- Choosing r+ or rb+ for a read-only blank. Any mode with a + allows writing too, and 'rb' is the read-only binary mode.
- Forgetting that seek(5) means seek(5, 0), because the default reference point is the beginning of the file.
- Opening a CSV file without newline='' and then getting blank lines in the output.
- Using 'w' when the question needs old records kept. 'w' erases the file, while 'a' adds at the end.
Using the Answer Key and Solutions
The PDF is 89 pages and free to download. Each section is sorted newest year first, the Answer Key lists every MCQ with options at a glance, and each question links to its worked solution and back. Attempt a section first, check the key, then read the solution. The solutions are written by Collegedunia's Computer Science experts and are not official CBSE marking schemes.
Class 12 Computer Science PYQs by Chapter
File Handling in Python Class 12 Computer Science PYQ FAQs
Ques. How many questions are in the File Handling in Python Class 12 PYQ PDF?
Ans. The PDF has 71 questions: 24 from the 2023 to 2026 CBSE board papers and 47 from CBSE's official sample papers. 38 are one-mark MCQs, 13 are 3-mark short answers, 9 are 4-mark case studies and 11 are 5-mark programs.
Ques. Does this PYQ PDF include solutions, or only the questions?
Ans. All 71 questions have a worked solution, and the 37 MCQs with options also have an Answer Key before the solutions.
Ques. Are the solutions official?
Ans. No. They are written by Collegedunia's Computer Science experts, run and checked against CBSE's marking schemes where CBSE has published them (2023, 2024 and 2025 board papers and the sample papers). The 2022 and 2026 board papers have no published scheme, so those answers were worked out and run by hand. They are not an official CBSE marking scheme.
Ques. How many marks does File Handling in Python carry in the Class 12 Computer Science paper?
Ans. CBSE publishes marks per unit, not per chapter. File Handling sits in Unit 1, Computational Thinking and Programming - 2, which carries about 40 of the 70 theory marks. Check the current curriculum on cbseacademic.nic.in.
Ques. Which topics are asked most from File Handling in Python?
Ans. Text files appear in 30 questions, CSV files in 19, binary files and pickle in 18, and seek() or tell() in 8. Counts overlap because one question can name two file types.
Ques. What is the difference between the r+ and w+ modes?
Ans. Both allow reading and writing. r+ needs the file to exist and keeps its content, while w+ creates the file if it is missing and erases anything already inside. This is asked directly in one 3-mark question.
Ques. Does the file pointer start at the end in append mode?
Ans. Yes. In mode 'a' the pointer sits at the end of the file, so new data is added after the existing content and nothing is erased.







Comments