Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary BINARY FILES

Rating
-
Sold
-
Pages
5
Uploaded on
11-10-2025
Written in
2025/2026

Its about binary programming: where to use specific thing and when to use them.

Institution
Course

Content preview

Binary Files:
1. Binary files are made up of non-human readable characters and symbols, which require specific programs to
access its contents.

2. In Binary File, translation is not required because data is stored in bytes form.

3. Faster than text files.

4. pickle module is used for working with binary files

5. File extension will be .dat

6. There is no delimiter to end the file.

Working in Binary files:
pickle module: pickle module is used in binary file for load( ) and dump( ) methods which are used for
reading and writing into binary file respectively.

Pickling or Serialization: It is the process of converting python object into byte stream.

Pickling is done at the time of writing into a binary file.

Unpickling or De-serialization: It is the process of converting a byte stream into python object.

Unpickling is done at the time reading from a binary file

dump( ): is used to write data into binary file. load( ): it is used to read data from binary file.
Syntax: identifier = pickle.dump(data , file_pointer) Syntax: identifier = pickle.load(file_pointer)
Example: a= “My name is Anuj” Example: data = pickle.load(f) #Here ‘data’ is an
pickle.dump(a,f) #here ‘a’ contains data and ‘f’ is a identifier and ‘f’ is a file pointer.
file pointer.
File modes in Binary File
Mode Description Behavior
rb Read-only in binary mode Opens the file for reading binary
data. File must exist; otherwise, it
raises an error.
rb + Read and write in binary mode. Opens the file for both reading and
writing binary data. File must
exist; otherwise, it raises an error.
wb Write in binary mode. Opens the file for writing binary
data. Creates a new file or
truncates the existing file.
wb + Write and read in binary mode. Write and read in binary mode.

ab Append in binary mode. Opens the file for appending
binary data. Creates a new file if it
doesn't exist.
ab+ Append and read in binary mode. Opens the file for appending and
reading binary data. Creates a new
file if it doesn't exist.

, Sample Program-1 (CBSE 2025)




import pickle
def Create():
f=open("PASSENGERS.dat","wb")
while True:
P=input("Enter the PNR")
PName=input("Enter the name")
BRDSTN=input("Enter the Bording Station")
DESTN=input("Enter the Destination Station")
FARE=float(input(“Enter the Fare”))
d=[P,PName,BRDSTN,DESTN,FARE]
pickle.dump(d,f)
ch=input("Do u want to add y/n")
if ch in "nN":
break
f.close()
def SearchDestn(D):
f=open("PASSENGERS.dat","rb")
rec=pickle.load(f)
try:

Written for

Institution
Secondary school
School year
1

Document information

Uploaded on
October 11, 2025
Number of pages
5
Written in
2025/2026
Type
SUMMARY

Subjects

$15.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
arshidaarsheya

Get to know the seller

Seller avatar
arshidaarsheya
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
8 months
Number of followers
0
Documents
9
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions