0% found this document useful (0 votes)
1 views6 pages

For Print Student Management Project Using Binary File Handling

The document outlines a Python program for a Student Management System that uses binary files to store student records. It includes functions to create, update, delete, search, and display student records, utilizing the pickle module for data serialization. The program features a menu-driven interface for user interaction.

Uploaded by

vaibhav Bhutani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views6 pages

For Print Student Management Project Using Binary File Handling

The document outlines a Python program for a Student Management System that uses binary files to store student records. It includes functions to create, update, delete, search, and display student records, utilizing the pickle module for data serialization. The program features a menu-driven interface for user interaction.

Uploaded by

vaibhav Bhutani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

#print("*******************************************************************")

#print("*********** STUDENT MANAGEMENT PROJECT USING BINARY FILE***********"


#print("*******************************************************************")
import pickle
def write():
print("\n******************* ADD NEW STUDENT RECORD(S) **************************")
f=open('student.dat','wb+')
srec=[]
while True:
rno=int(input("Enter Roll No: "))
name=input("Enter Name: ")
marks=int(input("Enter Marks : "))
data=[rno,name,marks]
srec.append(data)
ch=input("Wish to add nore records (Y/N)?")
if ch in 'Nn':
break
pickle.dump(srec,f)
print("NEW STUDENT RECORD(S) ADDED!!")
f.close()
def add():
print("\n*******************ADDING STUDENT RECORDS **************************")
f=open('student.dat','ab')
srec=[]
while True:
rno=int(input("Enter Roll No: "))
name=input("Enter Name: ")
marks=int(input("Enter Marks: "))
data=[rno,name,marks]
srec.append(data)
ch=input("Wish to add nore records (Y/N)?")
if ch in 'Nn':
break
pickle.dump(srec,f)
print("STUDENT RECORD ADDED!!")
f.close()
def update():
print("\n******************* UPDATING a STUDENT RECORD **************************")
f=open('student.dat','rb+')
rno=int(input("Enter Roll No to update : "))
f.seek(0)
try:
while True:
pos = f.tell()
s=pickle.load(f)
for i in s:
if i[0] == rno:
i[1] = input("Enter New Name: ")
i[2] =int(input("Enter New Marks: "))
f.seek(pos)
pickle.dump(s,f)
print("STUDENT RECORD UPDATED SUCCESSFULLY!!")
break
except Exception:
f.close()
def delete():
print("\n******************* DELETING A STUDENT RECORD **************************")
f=open('student.dat','rb')
s=pickle.load(f)
f.close()
rno=int(input("Enter Roll No to delete : "))
f=open('student.dat','wb+')
rec=[]
for i in s:
if rno == i[0]:
continue
else:
rec.append(i)
pickle.dump(rec,f)
print("STUDENT RECORD DELETED SUCCESSFULLY!!")
f.close()
def search():
print("\n******************* SEARCHING A STUDENT RECORD **************************")
s = []
f=open('student.dat','rb')
rno=int(input("Enter Roll No to search : "))
found=0
try:
while True:
s=pickle.load(f)
for i in s:
if i[0] == rno:
print("----------------------------------------------------------------------")
print("Roll No. : ",i[0])
print("Name : ",i[1])
print("Marks : ",i[2])
print("----------------------------------------------------------------------")
found = 1
except EOFError:
if found == 0:
print("The Roll No. not Found!!!!")
else:
print("Search successfull!!!!")
f.close()
def display():
print("\n******************* DISPLAYING STUDENT RECORDS **************************")
f=open('student.dat','rb')
try:
while True:
s=pickle.load(f)
for i in s:
print("Roll No. : ",i[0])
print("Name : ",i[1])
print("Marks : ",i[2])
print("----------------------------------------------------------------------")
except Exception:
f.close()
def menu():
reply="y"
while (reply=='y' or reply=='Y'):
print("************************************************************")
print("*************** STUDENT MANAGEMENT PROJECT*****************")
print("************************************************************")
print("\n 1. CREATE STUDENT RECORDS")
print("\n 2. UPDATE STUDENT RECORD")
print("\n 3. DELETE STUDENT RECORD")
print("\n 4. DISPLAY STUDENT RECORDS")
print("\n 5. SEARCH A STUDENT RECORD")
print("\n 6. ADD STUDENT RECORDS")
print("\n 7. EXIT")
ch =int(input( "\n ENTER CHOICE :"))
if ch == 1:
write()
elif ch == 2:
update()
elif ch == 3:
delete()
elif ch == 4:
display()
elif ch == 5:
search()
elif ch == 6:
add()
elif ch == 7:
print("\n Exiting.......")
break
else:
print("\n WRONG CHOICE")
reply = input("\n DO YOY WISH TO CONTINUE (Y/N)? ")
menu()

You might also like