0% found this document useful (0 votes)
84 views

Computer Science Project1

This document contains the source code for a Python project that allows storing, modifying, and viewing student records. The code defines classes to represent student data and functions for tasks like adding, searching, modifying, deleting student records from a pickled data file. It also has functions to generate class reports by counting pass/fail students or viewing subject-wise marks breakdown. The main program allows selecting these file management and student report options.

Uploaded by

avram john
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)
84 views

Computer Science Project1

This document contains the source code for a Python project that allows storing, modifying, and viewing student records. The code defines classes to represent student data and functions for tasks like adding, searching, modifying, deleting student records from a pickled data file. It also has functions to generate class reports by counting pass/fail students or viewing subject-wise marks breakdown. The main program allows selecting these file management and student report options.

Uploaded by

avram john
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/ 45

COMPUTER SCIENCE

PYTHON

PROJECT REPORT FILE


(SESSION 2019-2020)

SUBMITTED TO: SUBMITTED BY:

Mr. SPS CHAND VEDANT SINGH CHAUHAN

(COMPUTER SCIENCE) CLASS: XII


ACKNOWLEDGEMENT

I would like to thank mr. Sherpal


Singh Chand for his
uninterrupted guidance and the
computer department as a whole
for their support, also
to HM, DHM and the bursar to set
up an amaizing computer lab at
The Lawrence school, Lovedale.

VEDANT SINGH CHAUHAN

CLASS: XII B
PROJECT CODE:

from pickle import load,dump


from os import remove,rename
class studentclass:
def __init__(self):
self.name=""
self.rno=0
self.marks=[0,0,0,0,0]
self.per=0.0
self.sum=0.0

def getd(self):
self.name=input("Enter name :")
print()
self.rno=int(input("Enter rno"))
print()
self.marks[0]=float(input("Enter English
marks :"))
self.marks[1]=float(input("Enter Math
marks :"))
self.marks[2]=float(input("Enter Physics
marks :"))
self.marks[3]=float(input("Enter
Chemistry marks :"))
self.marks[4]=float(input("Enter
Computer Science :"))
print()
self.sum=sum(self.marks)
self.per=self.sum/5
def dispd(self):
print("Roll No. :",self.rno)
print("Name :",self.name)
print()
print("+++++++++++++++++++++++++")
print("+English Marks:
+",self.marks[0])
print("+Math Marks:
+",self.marks[1])
print("+Physics Marks:
+",self.marks[2])
print("+Chemistry Marks:
+",self.marks[3])
print("+Computer Science
Marks:+",self.marks[4])
print("+++++++++++++++++++++++++")
print()
print("Overall Average is :",self.per)

def add():
a1=studentclass()

fp=open("d:\\classreportproject.dat","a+b")
a1.getd()
dump(a1,fp)
fp.flush()
fp.close()

def modi():
en=int(input("Enter rno of the object you
desire to change :"))
fp=open("d:\\classreportproject.dat","rb")
fp1=open("d:\\temp.dat","wb")
c=0
try:
while True:
a2=load(fp)
if a2.rno==en:
c=1
a2.getd()
dump(a2,fp1)
fp1.flush()
else:
dump(a2,fp1)
fp1.flush()
except EOFError:
pass
fp.close()
fp1.close()
from os import remove,rename
remove("d:\\classreportproject.dat")

rename("d:\\temp.dat","d:\\classreportproj
ect.dat")
if c==1:
print("RECORD MODIFIED.........")
else:
print("Record with given rno doesn't
exist")
def count():
fp=open("d:\\classreportproject.dat","rb")
passed=0
failed=0
try:
print()
while True:
a2=studentclass()
a2=load(fp)
if a2.per>=33:
passed+=1
else:
failed+=1
except EOFError:
pass
print("Number of students that
passed:",passed)
print()
print("Number of students that
failed:",failed)
fp.close()
def disprec():

fp=open("d:\\classreportproject.dat","rb")
try:
print()
print("NAME\t\tRNO\t\tMARKS")
while True:
a2=load(fp)
a2.dispd()
except EOFError:
print("END OF FILE.........")
fp.close()
def delrec():
en=int(input("Enter rno of the object you
desire to delete :"))

fp=open("d:\\classreportproject.dat","rb")
fp1=open("d:\\temp.dat","wb")
c=0
try:
while True:
a2=studentclass()
a2=load(fp)
if a2.rno==en:
c=1
fp1.flush()
pass
else:
dump(a2,fp1)
fp1.flush()
except EOFError:
pass
fp.close()
fp1.close()
from os import remove,rename
remove("d:\\classreportproject.dat")

rename("d:\\temp.dat","d:\\classreportproj
ect.dat")
if c==1:
print("<<<<<<<<<<<<<<RECORD
DELETED>>>>>>>>>>>>>>>>")
else:
print(" SORRY GIVEN ROLL NO.
RECORD DOES NOT EXIST !!!!!!!!")
def search():
print()
en=int(input("Enter rno of the object you
desire to view :"))

fp=open("d:\\classreportproject.dat","rb")
c=0
try:
while True:
a2=studentclass()
a2=load(fp)
if a2.rno==en:
c=1
a2.dispd()
if a2.per>=33:
print("RESULT: PASSED")
else:
print("RESULT\: FAILED")
pass
except EOFError:
pass
if c!=1:
print("Record does not exist")
print()
fp.close()
def subj():
print()
print("L I S T OF S U B J E C T S ")
print("+++++++++++++++")
print("+1. English +")
print("+2. Math +")
print("+3. Physics +")
print("+4. Chemistry +")
print("+++++++++++++++")
print()
x=int(input("Enter the Number of the
Subject you wish to view."))-1
s=[]

fp=open("d:\\classreportproject.dat","rb")
c=0
try:
while True:
a2=studentclass()
a2=load(fp)
s.append(a2.marks[x])
except EOFError:
pass
fp.close()
print()
print("Maximum marks:",max(s))
print("Minimum marks:",min(s))
print("Average of the
Class:",sum(s)/len(s))
# FILE MANAGEMENT
def filemanagementmenu():
choi=0
while choi!=6:
print()
print("\tF I L E M A N A G E M E N T")
print()
print("+++++++++++++++++++++++")
print("+1. Add Record +")
print("+2. Search for Record +")
print("+3. Modify Record +")
print("+4. Delete Record +")
print("+5. View All Records +")
print("+6. Quit +")
print("+++++++++++++++++++++++")
print()
choi=int(input("Enter your choice"))
print()
if choi==1:
add()
elif choi==2:
search()
elif choi==3:
modi()
elif choi==4:
delrec()
elif choi==5:
disprec()
# STUDENT REPORT
def STUDENTRECORD():
choi=0
while choi!=4:
print()
print()
print("\tS T U D E N T R E P O R T")
print()

print("++++++++++++++++++++++++++++++
+")
print("+1. Class Report +")
print("+2. Individual Student Report +")
print("+3. Subjectwise Report +")
print("+4. Quit +")

print("++++++++++++++++++++++++++++++
+")
print()
choi=int(input("ENTER YOUR CHOICE
:"))
print()
if choi==1:
count()
elif choi==2:
search()
elif choi==3:
subj()

# MAIN PROGRAM
ch=0
while ch!=3:
print()
print("++++++++++++++++++++++++++++++
+++++++++++++++++")
print("+ S T U D E N T R E P O R T S Y S
T E M +")
print("+ +")
print("+ 1. F I L E M A N A G E M E N T
+")
print("+ 2. S T U D E N T R E P O R T
+")
print("+ 3. E X I T +")

print("++++++++++++++++++++++++++++++
+++++++++++++++++")
print()
ch=int(input("E N T E R Y O U R C H O I
C E :"))
if(ch==1):
filemanagementmenu()
elif ch==2:
STUDENTRECORD()
elif ch==3:
print("THANK YOU FOR USING OUR
REPORT SYSTEM....")
print("HAVE A NICE DAY!!!")
else:
print("Sorry! CHOICES POSSIBLE(1-3)")
OUTPUT:
======== RESTART:
C:\Users\Student\Downloads\StudentRepor
tProject2.py ========

++++++++++++++++++++++++++++++++++++
+++++++++++
+ STUDENT REPORT SYSTEM+
+ +
+ 1. F I L E M A N A G E M E N T +
+ 2. S T U D E N T R E P O R T +
+ 3. E X I T +
++++++++++++++++++++++++++++++++++++
+++++++++++

E N T E R Y O U R C H O I C E :1

FILE MANAGEMENT

+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice1

Enter name : Rohan Yanni Prasad

Enter rno1

Enter English marks :100


Enter Math marks :100
Enter Physics marks :100
Enter Chemistry marks :100
Enter Computer Science :99
FILE MANAGEMENT

+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice1

Enter name : Bedant Singh Chauhan


Enter rno2

Enter English marks :98


Enter Math marks :87
Enter Physics marks :76
Enter Chemistry marks :65
Enter Computer Science :54

FILE MANAGEMENT

+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice3

Enter rno of the object you desire to change


:2
Enter name : Mukesh kumar

Enter rno2

Enter English marks :12


Enter Math marks :23
Enter Physics marks : 34
Enter Chemistry marks : 45
Enter Computer Science : 56

RECORD MODIFIED.........

FILE MANAGEMENT

+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice4

Enter rno of the object you desire to delete


:2
<<<<<<<<<<<<<<RECORD
DELETED>>>>>>>>>>>>>>>>

FILE MANAGEMENT

+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice5

NAME RNO MARKS


Roll No. : 1
Name : Rohan Yanni Prasad

+++++++++++++++++++++++++
+English Marks: + 100.0
+Math Marks: + 100.0
+Physics Marks: + 100.0
+Chemistry Marks: + 100.0
+Computer Science Marks:+ 99.0
+++++++++++++++++++++++++

Overall Average is : 99.8


END OF FILE.........

FILE MANAGEMENT

+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice1

Enter name :George C

Enter rno2

Enter English marks :12


Enter Math marks :13
Enter Physics marks :14
Enter Chemistry marks :15
Enter Computer Science :16
FILE MANAGEMENT

+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice5


NAME RNO MARKS
Roll No. : 1
Name : Ishaan Yanni Prasad

+++++++++++++++++++++++++
+English Marks: + 100.0
+Math Marks: + 100.0
+Physics Marks: + 100.0
+Chemistry Marks: + 100.0
+Computer Science Marks:+ 99.0
+++++++++++++++++++++++++

Overall Average is : 99.8


Roll No. : 2
Name : George C

+++++++++++++++++++++++++
+English Marks: + 12.0
+Math Marks: + 13.0
+Physics Marks: + 14.0
+Chemistry Marks: + 15.0
+Computer Science Marks:+ 16.0
+++++++++++++++++++++++++

Overall Average is : 14.0


END OF FILE.........

FILE MANAGEMENT
+++++++++++++++++++++++
+1. Add Record +
+2. Search for Record +
+3. Modify Record +
+4. Delete Record +
+5. View All Records +
+6. Quit +
+++++++++++++++++++++++

Enter your choice6

++++++++++++++++++++++++++++++++++++
+++++++++++
+ STUDENT REPORT SYSTEM+
+ +
+ 1. F I L E M A N A G E M E N T +
+ 2. S T U D E N T R E P O R T +
+ 3. E X I T +
++++++++++++++++++++++++++++++++++++
+++++++++++

E N T E R Y O U R C H O I C E :2

STUDENT REPORT

+++++++++++++++++++++++++++++++
+1. Class Report +
+2. Individual Student Report +
+3. Subjectwise Report +
+4. Quit +
+++++++++++++++++++++++++++++++

ENTER YOUR CHOICE :1

Number of students that passed: 1

Number of students that failed: 1

STUDENT REPORT

+++++++++++++++++++++++++++++++
+1. Class Report +
+2. Individual Student Report +
+3. Subjectwise Report +
+4. Quit +
+++++++++++++++++++++++++++++++

ENTER YOUR CHOICE :2

Enter rno of the object you desire to view :1


Roll No. : 1
Name : Ishaan Yanni Prasad

+++++++++++++++++++++++++
+English Marks: + 100.0
+Math Marks: + 100.0
+Physics Marks: + 100.0
+Chemistry Marks: + 100.0
+Computer Science Marks:+ 99.0
+++++++++++++++++++++++++

Overall Average is : 99.8


RESULT: PASSED

STUDENT REPORT

+++++++++++++++++++++++++++++++
+1. Class Report +
+2. Individual Student Report +
+3. Subjectwise Report +
+4. Quit +
+++++++++++++++++++++++++++++++

ENTER YOUR CHOICE :3

LIST OF SUBJECTS
+++++++++++++++
+1. English +
+2. Math +
+3. Physics +
+4. Chemistry +
+++++++++++++++
Enter the Number of the Subject you wish
to view.1

Maximum marks: 100.0


Minimum marks: 12.0
Average of the Class: 56.0

STUDENT REPORT

+++++++++++++++++++++++++++++++
+1. Class Report +
+2. Individual Student Report +
+3. Subjectwise Report +
+4. Quit +
+++++++++++++++++++++++++++++++

ENTER YOUR CHOICE :4

++++++++++++++++++++++++++++++++++++
+++++++++++
+ STUDENT REPORT SYSTEM+
+ +
+ 1. F I L E M A N A G E M E N T +
+ 2. S T U D E N T R E P O R T +
+ 3. E X I T +
++++++++++++++++++++++++++++++++++++
+++++++++++
E N T E R Y O U R C H O I C E :3
THANK YOU FOR USING OUR REPORT
SYSTEM....
HAVE A NICE DAY!!!

You might also like