0% found this document useful (0 votes)
189 views4 pages

Student Record Management System

The document contains code to perform CRUD operations on a student dictionary stored as a pickle file. It defines functions to create, display, search by stream, update percent, and delete a record from the dictionary file.
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)
189 views4 pages

Student Record Management System

The document contains code to perform CRUD operations on a student dictionary stored as a pickle file. It defines functions to create, display, search by stream, update percent, and delete a record from the dictionary file.
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

#{adm: ____, name: ____, percent: ___, stream: ___}

import pickle
import os

def CREATE():
f=open('Stud_DICT.dat', 'wb')
A=int(input('Enter admission number: '))
N=input('Enter name: ')
P=float(input('Enter percent: '))
if P>=90: S='Science'
elif 75<=P<90: S='Commerce'
else: S='Humanities'
R={'adm': A, 'name': N, 'percent': P, 'stream': S}
[Link](R, f)
[Link]()

def DISPLAY():
try:
f=open('Stud_DICT.dat', 'rb')
try:
while True:
R=[Link](f)
print(R)
except EOFError:
pass
[Link]()
except FileNotFoundError:
print('No such file')
def SEARCH_STREAM():
try:
f=open('Stud_DICT.dat', 'rb')
S=input('Enter stream to search: ')
try:
flag=False
while True:
R=[Link](f)
if R['stream'].upper()==[Link]():
flag=True
print(R)
except EOFError:
[Link]()
if not flag:
print('Record not found')
except FileNotFoundError:
print('No such file')
def UPDATE_PERCENT():
try:
f=open('Stud_DICT.dat', 'rb+')
pos=0
flag=False
A=int(input('Enter admission number to update percent: '))
try:
while True:
R=[Link](f)
if R['adm']==A:
flag=True
R['percent']=float(input('Enter updated percent: '))
[Link](pos)
[Link](R, f)
break
else:
pos=[Link]()
except EOFError:
[Link]()
if flag:
print('Record updated successfully')
else:
print('Record not found')
except FileNotFoundError:
print('No such file')
def DELETE_REC():
try:
f1=open('Stud_DICT.dat', 'rb')
f2=open('[Link]', 'wb')
A=int(input('Enter admission number to delete record: '))
try:
flag=False
while True:
R=[Link](f1)
if R['adm']==A:
flag=True
continue
else:
[Link](R, f2)
except EOFError:
[Link]()
[Link]()
if flag:
[Link]('Stud_DICT.dat')
[Link]('[Link]', 'Stud_DICT.dat')
print('Record deleted successfully')
else:
[Link]('[Link]')
print('Record not found')
except FileNotFoundError:
print('No such file')

You might also like