Class 12 Computer Science: Python Revision and File Handling Worksheet
This worksheet tests your understanding of fundamental Python concepts and file handling operations, crucial for Class 12 Computer Science.
Your device's Print screen will open — choose "Save as PDF" to download.
Track practice: print a star chart
- Q1.Which of the following modes is used to open a file for both reading and writing, creating it if it doesn't exist, and overwriting its contents if it does?
- A.'r+'
- B.'w+'
- C.'a+'
- D.'x'
- Q2.What will be the output of the following Python code snippet? ```python def func(a, b=5): print(a - b) func(10) func(b=2, a=8) ```
- A.5 6
- B.5 -6
- C.-5 6
- D.-5 -6
- Q3.The `____` method in file handling is used to read at most 'n' bytes from the file.
- Q4.Which of the following is an immutable data type in Python?
- A.List
- B.Dictionary
- C.Tuple
- D.Set
Preview — full sheet in the PDF
What's inside this workbook
This Class 12 Computer Science Practice contains 10 questions across 2 printable pages and includes a full answer key at medium difficulty. Aligned to the CBSE and NCERT syllabus.
How this worksheet helps your child
- Builds confidence in core Computer Science concepts taught in Class 12 through repeated, varied practice.
- Aligned to CBSE and NCERT — questions mirror the pattern children see in school tests and unit assessments.
- Comes with an answer key so parents and students can self-check in minutes, without needing a teacher.
- Pitched at medium level — use it for daily homework, weekend revision or quick exam warm-ups.
About this worksheet
Embark on a comprehensive review of essential programming principles with our Class 12 Computer Science Python Revision and File Handling Practice Worksheet. Tailored specifically for CBSE students, this medium-difficulty resource is designed to solidify understanding of Python fundamentals and critical file handling operations. As students prepare for important examinations, mastering these concepts becomes paramount. This worksheet is ideal for students who have covered topics in Python programming and are now looking to reinforce their knowledge, identify areas for improvement, and gain confidence in tackling practical problems. It provides an excellent opportunity to apply theoretical knowledge in a structured practice environment, ensuring a strong foundation in Computer Science as per the NCERT and CBSE curriculum guidelines. Teachers can use it for in-class assessments or homework, while parents can utilize it to support their child's independent study.
What your child will learn
- Practice core Python programming constructs and syntax.
- Identify different modes of opening and closing files in Python.
- Apply methods for reading data from various types of files.
- Solve problems involving writing and appending data to files.
- Recognise common errors in file handling and debug Python code effectively.
Understanding the concept
File handling in computer science refers to the process by which computer programs interact with files stored on a sustained storage device, like a hard drive or SSD. Think of it like managing physical documents in a real-world office. If you need to read a report, you open the file. If you need to write a new one, you create or open an existing file and then write into it. Similarly, Python programs can open files, read their content, write new content into them, or add content to existing files (append). This is crucial because programs often need to store information permanently – whether it's user data, configuration settings, or results of calculations – which isn't possible if data only exists while the program is running. For example, a simple Python program might ask a user for their name and then save that name into a text file, so the next time the program runs, it can greet the user by name. This involves opening the file in 'write' or 'append' mode to save the name, and then opening it in 'read' mode to retrieve it later. Proper file handling also includes making sure files are closed after use, much like putting a document back in its folder, to prevent data corruption or resource leaks.
Tips for parents & teachers
- Encourage your child to attempt the worksheet independently first, without referring to notes or textbooks.
- After completion, review the answers together and discuss any incorrect solutions to understand the underlying concepts.
- Suggest your child write small Python programs on a computer to test out file handling operations physically.
- For challenging questions, guide them to break down the problem into smaller, manageable steps.
- Use this worksheet as a diagnostic tool to identify specific areas where extra practice or revision is needed.
Topics covered
How to use this worksheet at home
Open the print view and use your browser's Print dialog to print on regular A4 paper or save as a PDF. Hand the printed sheet to your child (Class 12) and set a relaxed time limit — 15 to 25 minutes works for most Computer Science worksheets. When they're done, open the "With answer key" view and let them self-mark question by question. Re-print as many times as you need; the file never expires and there's no download limit.
Frequently asked questions
- Is this Computer Science worksheet really free?
- Yes — every workbook on WorkbookWala is 100% free to download and print. No login, no email, no paywall. We're free for students, parents and teachers.
- Is it aligned to the CBSE / NCERT syllabus?
- Yes. All Class 12 worksheets are built around the CBSE and NCERT pattern so they map cleanly to what your child is studying in school.
- Can I print this worksheet at home?
- Yes. Click "Open print view" and use your browser's Print dialog to print on standard A4 paper, or save it as a PDF for later. The layout is designed to fit cleanly without scaling.
- Does it include an answer key?
- Yes — click "With answer key" to print a version with answers included, so parents and students can self-mark in minutes.
More Computer Science worksheets for Class 12
View all →Class 12 Computer Networks & Security Basics
This worksheet tests fundamental knowledge of computer networking concepts and basic network security measures.
Class 12 Computer Science: Advanced SQL and Database Concepts
This worksheet challenges your understanding of advanced SQL queries, database normalization, transactions, and integrity constraints.
Class 12 Computer Science: Stack and Queue Fundamentals
This worksheet assesses your understanding of fundamental concepts related to Data Structures such as Stack and Queue, including their operations and applications.
Class 12 Computer Science: Functions and Recursion
This worksheet will test your understanding of defining and calling functions in Python, as well as the concept of recursion and its application.