""" to maintain student details
roll
name
physics
chemistry
maths
computer
english
total
per
grade
"""
"""
modules imported
"""
import pickle
import os
"""
class used
"""
class student(object):
def __int__(s):
[Link]=0
[Link]=" "
[Link]=0
[Link]=0
[Link]=0
[Link]=0
[Link]=0
[Link]=0
[Link]=0
[Link]=" "
def add_rec(s):
[Link]=int(input("Enter roll no"))
[Link]=input("Enter the name")
[Link]=[Link]()
[Link]=float(input("Enter marks of physics"))
[Link]=float(input("Enter marks of chemistry"))
[Link]=float(input("Enter marks of maths"))
[Link]=float(input("Enter marks of computer"))
[Link]=float(input("Enter marks of english"))
[Link]=[Link]+[Link]+[Link]+[Link]+[Link]
[Link]=[Link]/5
if([Link]>=90):
[Link]="A1"
elif([Link]>=80 and [Link]<90):
[Link]="A2"
elif([Link]>=70 and [Link]<80):
[Link]="B1"
elif([Link]>=60 and [Link]<70):
[Link]="B2"
else:
[Link]="C"
def disp_rec(s):
print("roll",[Link])
print("name",[Link])
print("physics",[Link])
print("chemistry",[Link])
print("maths",[Link])
print("computer",[Link])
print("english",[Link])
print("total",[Link])
print("per",[Link])
print("grade",[Link])
def display_rec(s):
print("%-8s"%[Link],"%-10s"%[Link],"%-10s"%[Link],"%-
12s"%[Link],"%-10s"%[Link],"%-8s"%[Link],"%-10s"%[Link],"%-
10s"%[Link],"%-10s"%[Link],"%-5s"%[Link])
#print("in display_rec")
def modify_rec(s):
[Link]=int(input("Enter new roll no"))
[Link]=input("Enter new name")
[Link]=[Link]()
[Link]=float(input("Enter new marks of physics"))
[Link]=float(input("Enter new marks of chemistry"))
[Link]=float(input("Enter new marks of maths"))
[Link]=float(input("Enter new marks of computer"))
[Link]=float(input("Enter new marks of english"))
def write_rec():
try:
rec=student()
file=open("[Link]","ab")
rec.add_rec()
[Link](rec,file)
[Link]()
print("Record added in file")
input("Press any key to cont....")
except:
pass
def display_all():
[Link]("cls")
print(110*"=")
print("\n RAMAKRISHNA VIDYA MANDIR
\n")
print("\n LIST OF MARKS OF STUDENTS OF CLASS XII
OPTING PCM \n")
print("\n -created by Mitushi
Chauhan \n")
print("\n STUDENT MARKSHEET
\n")
print(110*"=")
try:
file=open("[Link]","rb")
print("%-8s"%"Rollno","%-10s"%"Name","%-10s"%"Physics","%-
14s"%"Chemistry","%-8s"%"Maths","%-10s"%"Computer","%-10s"%"English","%-
10s"%"Total","%-8s"%"Per","%-5s"%"Grade")
print(110*"=")
while True:
rec=[Link](file)
rec.display_rec()
except EOFError:
[Link]()
print(110*"=")
input("Press any key to cont....")
except IOError:
print("File could not be opened")
def search_roll():
[Link]("cls")
try:
z=0
print(110*"=")
print("Record searching by roll no")
print(110*"=")
n=int(input("Enter roll no to search"))
file=open("[Link]","rb")
while True:
rec=[Link](file)
if([Link]==n):
z=1
print("\nRecord found and details are\n")
rec.disp_rec()
break
except EOFError:
[Link]()
if(z==0):
print("Record is not present")
except IOError:
print("File could not be opened")
input("Press Enter to cont....")
def search_name():
[Link]("cls")
try:
z=0
n=input("Enter name to search ")
file=open("[Link]","rb")
while True:
rec=[Link](file)
if([Link]==[Link]()):
z=1
rec.disp_rec()
break
except EOFError:
[Link]()
if(z==0):
print("Record is not present")
except IOError:
print("File could not be opened")
input("Press Enter to cont....")
def modify_roll():
[Link]("cls")
z=0
try:
n=int(input("Enter roll no to modify"))
file=open("[Link]","rb")
temp=open("[Link]","wb")
while True:
rec=[Link](file)
if([Link]==n):
z=1
print("Record found and details are")
rec.disp_rec()
print("Enter new data")
rec.modify_rec()
[Link](rec,temp)
print("Record updated")
else:
[Link](rec,temp)
except EOFError:
[Link]()
[Link]()
if(z==0):
print("Record not found")
except IOError:
print("File could not be opened")
[Link]("[Link]")
[Link]("[Link]","[Link]")
input("Press Enter to cont....")
def delete_roll():
[Link]("cls")
z=0
try:
n=int(input("Enter roll no to delete"))
file=open("[Link]","rb")
temp=open("[Link]","wb")
while True:
rec=[Link](file)
if([Link]==n):
z=1
print("Record to delete found and details are")
rec.disp_rec()
else:
[Link](rec,temp)
except EOFError:
[Link]()
[Link]()
if(z==0):
print("Record not found")
except IOError:
print("File could not be opened")
[Link]("[Link]")
[Link]("[Link]","[Link]")
input("Press Enter to cont....")
while True:
[Link]("cls")
print(110*"=")
print(""" Main Menu
------------------------
1. Add record
2. Display all records
3. Search by rollno
4. Search by name
5. Modify by rollno
6. Delete by rollno
7. Exit
""")
print(110*"=")
ch=int(input("Enter your choice"))
print(110*"=")
if(ch==1):
write_rec()
elif(ch==2):
display_all()
elif(ch==3):
search_roll()
elif(ch==4):
search_name()
elif(ch==5):
modify_roll()
elif(ch==6):
delete_roll()
elif(ch==7):
print("END")
break
else:
print("INVALID CHOICE")