File Handling || Notes || Sumita Arora || Class 12 || Computer science || Information practices
PDF Download link given below of this Blog
File Handling
Data Files: - The data files are the files that
store data pertaining to specific application, for later use. The data files
can be store in two ways:
• Text files
• Binary files
OPENING AND CLOSING
FILES
Opening files: -
In data file handling through
Python, the first thing that you do is open the file. It is done using open()
function as per one of the following syntax:
<file object name>=open(<file name>)
<file object name>=open(<file
name>,<mode>)
For example:
stu = open ("students.txt")
The above statement open file "students.txt" in file mode as read mode (default mode) and attaches
it to file object namely stu.
Consider another statement:
stu = open ("students.txt","r")
The above statement opens the file "students.txt" in read mode
(because of "r" given as mode) and attaches it to file object namely
stu.
Consider one more file open statement: -
stu = open ("e:\\main\\students.txt","w")
The above statement open file "students.txt"(stored in folder
e:\main) in write mode (because of "w" given as mode) and attaches it
to file object namely stu.
• Please note that when you open a file
in read mode, the given file must exist in folder, otherwise Python will raise
error.
File Object/ File Handle:
- A file object is a reference to a
file on disk. It opens and makes it available for a number of different tasks.
File Access Modes: -
• A file-mode governs the type
of operations (e.g., read/write/append) possible in the opened file i.e., it
refers to how the file will be used once it's opened.
Closing File: -
A close ()
function breaks the link of file object and the file on the disk. After close
(), no tasks can be performed on that file through the file object (or file
handle).
READING AND WRITING FILES: -
Reading from Files: -
Writing onto Files: -
PATHNAME: - The full name of a file or a
file directory is called pathname.
For example: -
E:\work\project
Thankyou!!!!!
For Sumita Arora Type C solution ( Programing Question ) Visit our YouTube Channel Portal Express
For Solution of Sumita Arora visit on Path Wala
Please provide complete notes to us.
ReplyDeleteok , i will upload very soon..... : )
DeleteNotes can't be downloaded ...pl plea solve m
ReplyDeletePlease try again.
DeletePlease provide pdf of sumita Arora class 12.
ReplyDeletewatch it https://www.youtube.com/watch?v=nd_Z-bO6rb0&t=23s
DeleteBro how see solutions
ReplyDeleteClick on this link :- https://www.pathwalla.com/2020/03/python-class-12-solution-sumita-arora-type-c.html
DeleteAre these notes enough for school level exams?
ReplyDeleteYes.
DeleteOnly these notes are kk for schools exams and for boards also 💁♀️💁♀️🤔🙂
ReplyDeletePlease complete full notes tomorrow having exam
ReplyDeletekal aana kal
Deleteok.
DeleteSir please help me I don't know password
ReplyDeleteWhich pdf.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )