0% found this document useful (0 votes)
3 views8 pages

#Source Code

The document contains a Python program that manages student records stored in a file named 'MARKS.DAT'. It provides a menu-driven interface for users to search for records by name, display records with theory marks below 50, update practical marks, and delete records based on total marks. The program utilizes the pickle module for serialization and deserialization of data, and handles various exceptions during file operations.

Uploaded by

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

#Source Code

The document contains a Python program that manages student records stored in a file named 'MARKS.DAT'. It provides a menu-driven interface for users to search for records by name, display records with theory marks below 50, update practical marks, and delete records based on total marks. The program utilizes the pickle module for serialization and deserialization of data, and handles various exceptions during file operations.

Uploaded by

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

#VRATTESH ANAND

#CLASS-12 SECTION-B
#ROLL NO:35
#Q14:
#source code:
import pickle
def function11():
f=open("MARKS.DAT",'rb')
c=0
NaMe=input("enter name")
while True:
try:
v=pickle.load(f)
if v[1]==NaMe:
print("rec found and searched")

print(v)

else:
print("not present")

except:
print('all records done')
break
f.close()

import pickle
def function22():
f=open("MARKS.DAT",'rb')
while True:
try:
v=pickle.load(f)
if float(v[2])<50:
print("rec found and searched")

print(v)

else:
print("not present")

except:
print('all records done')
break
f.close()

import pickle
def function33():
file=open("MARKS.DAT","rb")
f1=open("TEMP.DAT","ab")
try:
while True:
G=pickle.load(file)
if G[-2]<24.0:
G[-2]=G[-2]+2
G[-1]=G[-1]+2

pickle.dump(G,f1)
print("FILES ARE UPTO DATE, PLEASE VIEW THEM AS
ERROR DOESN'T TAKE PLACE")
else:
print('not present')
except:
print("error")

f1.close()
file.close()

import pickle,os
def function44():

file=open("MARKS.DAT","rb")
f1=open("TEMP.dat","ab")

try:
while True:
k=pickle.load(file)
if k[-1]>=70:
pickle.dump(k,f1)
else:
print("records deleted and printed")

except:
print("ERROR FOUND: NOT CONTINUE")

f1.close()
file.close()
os.rename("TEMP.DAT","MARKS2.DAT")

while True:

print("=========================================================
=menu===========================================================
=================================")

print("1.DISPLAY AND SEARCH NAME IN THE RECORDS ")


print("2.DISPLAY AND SEARCH WITH INPUTTED THEORY MARKS ")
print("3.DISPLAY AND SEARCHTHE RECORDS WITH PRACTICAL ")
print("4.DISPLAY AND SEARCH TTOT WITH INPUT")
print("0.EXIT FROM MENU")

ch=int(input("ENTER AN OPTION"))

if ch==1:
function11()
elif ch==2:
function22()
elif ch==3:
function33()
elif ch==4:
function44()
elif ch==0:
print("breaking from menu... BYE")
break
else:
print('object not found , OPTION not found')

#OUTPUT:
'''
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC
v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more
information.

========= RESTART:
C:/Users/neels/Documents/PYTHON-FILES/question14.py =========
==========================================================menu==
================================================================
==========================
1.DISPLAY AND SEARCH NAME IN THE RECORDS
2.DISPLAY AND SEARCH WITH INPUTTED THEORY MARKS
3.DISPLAY AND SEARCHTHE RECORDS WITH PRACTICAL
4.DISPLAY AND SEARCH TTOT WITH INPUT
0.EXIT FROM MENU
ENTER AN OPTION1
enter namevrat
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
all records done
==========================================================menu==
================================================================
==========================
1.DISPLAY AND SEARCH NAME IN THE RECORDS
2.DISPLAY AND SEARCH WITH INPUTTED THEORY MARKS
3.DISPLAY AND SEARCHTHE RECORDS WITH PRACTICAL
4.DISPLAY AND SEARCH TTOT WITH INPUT
0.EXIT FROM MENU
ENTER AN OPTION2
not present
rec found and searched
[2, 'AREEB AHMED', 47.0, 24.0, 71.0]
rec found and searched
[3, 'ADITI SINGH', 46.0, 25.0, 71.0]
rec found and searched
[4, 'AJAY RANA', 40.0, 26.0, 66.0]
not present
not present
not present
rec found and searched
[8, 'ASHWIN GUPTA', 47.0, 26.0, 73.0]
not present
not present
rec found and searched
[11, 'HAIDER SHAHED', 43.0, 23.0, 66.0]
rec found and searched
[12, 'PRINCE KEVIN', 37.0, 27.0, 64.0]
not present
not present
rec found and searched
[15, 'MADHU SRAVAN', 40.0, 23.0, 63.0]
not present
not present
not present
not present
not present
not present
not present
rec found and searched
[23, 'RAVI AHUJA', 48.0, 26.0, 74.0]
not present
rec found and searched
[25, 'SHAGHUN CHAUHAN', 40.0, 24.0, 64.0]
not present
not present
not present
all records done
==========================================================menu==
================================================================
==========================
==========================================================menu==
================================================================
==========================
1.DISPLAY AND SEARCH NAME IN THE RECORDS
2.DISPLAY AND SEARCH WITH INPUTTED THEORY MARKS
3.DISPLAY AND SEARCHTHE RECORDS WITH PRACTICAL
4.DISPLAY AND SEARCH TTOT WITH INPUT
0.EXIT FROM MENU
ENTER AN OPTION3
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
FILES ARE UPTO DATE, PLEASE VIEW THEM AS ERROR DOESN'T TAKE
PLACE
not present
not present
not present
FILES ARE UPTO DATE, PLEASE VIEW THEM AS ERROR DOESN'T TAKE
PLACE
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
not present
error
==========================================================menu==
================================================================
==========================
1.DISPLAY AND SEARCH NAME IN THE RECORDS
2.DISPLAY AND SEARCH WITH INPUTTED THEORY MARKS
3.DISPLAY AND SEARCHTHE RECORDS WITH PRACTICAL
4.DISPLAY AND SEARCH TTOT WITH INPUT
0.EXIT FROM MENU
ENTER AN OPTION4
records deleted and printed
records deleted and printed
records deleted and printed
records deleted and printed
records deleted and printed
ERROR FOUND: NOT CONTINUE
==========================================================menu==
================================================================
==========================
1.DISPLAY AND SEARCH NAME IN THE RECORDS
2.DISPLAY AND SEARCH WITH INPUTTED THEORY MARKS
3.DISPLAY AND SEARCHTHE RECORDS WITH PRACTICAL
4.DISPLAY AND SEARCH TTOT WITH INPUT
0.EXIT FROM MENU
ENTER AN OPTION0
breaking from menu... BYE
'''

You might also like