Advertisements
Online Mock Tests
Chapters
▶ 2: File Handling in Python
3: Stack
4: Queue
5: Sorting
6: Searching
7: Understanding Data
8: Database Concepts
9: Structured Query Language (SQL)
10: Computer Networks
11: Data Communication
12: Security Aspects
Chapter 13: Project Based Learning
![NCERT solutions for Computer Science [English] Class 12 chapter 2 - File Handling in Python NCERT solutions for Computer Science [English] Class 12 chapter 2 - File Handling in Python - Shaalaa.com](/images/computer-science-english-class-12_6:3cc34948e1364f88bfa74088b5693c7f.jpg)
Advertisements
Solutions for Chapter 2: File Handling in Python
Below listed, you can find solutions for Chapter 2 of CBSE NCERT for Computer Science [English] Class 12.
NCERT solutions for Computer Science [English] Class 12 2 File Handling in Python Exercise [Pages 37 - 38]
Differentiate between text file and binary file.
Differentiate between readline() and readlines().
Differentiate between write() and writelines().
Write the use and syntax for the following method:
open()
Write the use and syntax for the following method:
read()
Write the use and syntax for the following method:
seek()
Write the use and syntax for the following method:
dump()
Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file:
a text file “example.txt” in both read and write mode
Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file:
a binary file “bfile.dat” in write mode.
Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file:
a text file “try.txt” in append and read mode.
Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file:
a binary file “btry.dat” in read only mode.
Why is it advised to close a file after we are done with the read and write operations? What will happen if we do not close it? Will some error message be flashed?
What is the difference between the following set of statements (a) and (b):
- P = open(“practice.txt”,”r”)
P.read(10) - with open(“practice.txt”, “r”) as
P: x = P.read()
Write a command(s) to write the following lines to the text file named hello.txt. Assume that the file is opened in append mode.
“ Welcome my class”
“It is a fun place”
“You will learn and play”
Write a Python program to open the file hello.txt used below in read mode to display its contents. What will be the difference if the file was opened in write mode instead of append mode?
“ Welcome my class”
“It is a fun place”
“You will learn and play”
Write a program to accept string/sentences from the user till the user enters “END” to. Save the data in a text file and then display only those sentences which begin with an uppercase alphabet.
Define pickling in Python. Explain serialization and deserialization of Python object.
Write a program to enter the following records in a binary file:
| Item No | integer |
| Item_Name | string |
| Qty | integer |
| Price | float |
Number of records to be entered should be accepted from the user. Read the file to display the records in the following format:
Item No:
Item Name :
Quantity:
Price per item:
Amount: (to be calculated as Price * Qty)
Solutions for 2: File Handling in Python
![NCERT solutions for Computer Science [English] Class 12 chapter 2 - File Handling in Python NCERT solutions for Computer Science [English] Class 12 chapter 2 - File Handling in Python - Shaalaa.com](/images/computer-science-english-class-12_6:3cc34948e1364f88bfa74088b5693c7f.jpg)
NCERT solutions for Computer Science [English] Class 12 chapter 2 - File Handling in Python
Shaalaa.com has the CBSE Mathematics Computer Science [English] Class 12 CBSE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. NCERT solutions for Mathematics Computer Science [English] Class 12 CBSE 2 (File Handling in Python) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.
Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. NCERT textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.
Concepts covered in Computer Science [English] Class 12 chapter 2 File Handling in Python are Introduction to File Handling in Python, Types of Files in Python, Opening and Closing a Text Files in Python, Writing to a Text File in Python, Reading from a Text File in Python, Setting Offsets in a File in python, Creating and Traversing a Text File in Python, The Pickle Module in Python.
Using NCERT Computer Science [English] Class 12 solutions File Handling in Python exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in NCERT Solutions are essential questions that can be asked in the final exam. Maximum CBSE Computer Science [English] Class 12 students prefer NCERT Textbook Solutions to score more in exams.
Get the free view of Chapter 2, File Handling in Python Computer Science [English] Class 12 additional questions for Mathematics Computer Science [English] Class 12 CBSE, and you can use Shaalaa.com to keep it handy for your exam preparation.
