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

Computer Science Grade12

This document contains an acknowledgement section thanking various people for their support and guidance on a computer science project. It then lists various Python programs created as part of the project, including programs to reverse a string, find the highest common factor using functions, read and display lines from a file starting with 'T', create and add data to a text file, read a file and display character counts, programs involving quadratic equations, checking for buzz and Armstrong numbers, palindromes and factorials, and binary operations. It also contains a Python program to insert, read, search, update and delete student records from a binary file using pickling.

Uploaded by

Aadi Athreya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Computer Science Grade12

This document contains an acknowledgement section thanking various people for their support and guidance on a computer science project. It then lists various Python programs created as part of the project, including programs to reverse a string, find the highest common factor using functions, read and display lines from a file starting with 'T', create and add data to a text file, read a file and display character counts, programs involving quadratic equations, checking for buzz and Armstrong numbers, palindromes and factorials, and binary operations. It also contains a Python program to insert, read, search, update and delete student records from a binary file using pickling.

Uploaded by

Aadi Athreya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

COMPUTER SCIENCE

PROJECT FILE

MADE BY:
Aaditya.s.Athreya
XII-B
ACKNOWLEDGEMENT

I extend my deepest gratitude to my dedicated group


members, Ustat and Rudra, whose unwavering
commitment and exceptional teamwork played a
crucial role in shaping the success of our project.

I extend my deepest gratitude to my Ms. Megha Gupta


for her expert guidance and continuous support. Her
valuable inputs and encouragement significantly
contributed to the project's growth and refinement.
Furthermore, I'd like to acknowledge the remarkable
leadership of Mrs. Inderbir Thussu, our principal,
whose belief in our abilities bolstered our confidence.

Her vision and guidance have been instrumental in


driving us towards excellence. Lastly, I'd like to express
my heartfelt appreciation to my family for their
unconditional support, patience, and understanding
throughout this journey.
TRAVERSING AND REVERSING A STRING
Print HCF using functions
Program to read and display those lines from a file that start with the
alphabet ‘T
program to create a text file and add data
Program to read the content of file and display the total number of
consonants, uppercase, vowels and lower case characters.

QUADRATIC EQUATION
PROGRAM TO CHECK BUZZ AND ARMSTRONG NUMBER
PALINDROME AND FACTORIAL

ALL BINARY OPERATIONS

import pickle

#Accepting data for dictionary


def insertRec():
rollno=int(input("Enter roll number: "))
name=input("Enter name ")
marks=int(input("Enter marks "))
#creating the dictionary
rec={"Rollno":rollno,"Name":name,"Marks":marks}
#writing the dictionary
f=open("student.dat","ab")
pickle.dump(rec,f)
f.close()

#Reading the records


def readRec():
f=open("student.dat","rb")
while True:
try:
rec=pickle.load(f)
print("Roll no:",rec['Rollno'])
print("Name:",rec["Name"])
print("Marks:",rec["Marks"])
except EOFError:
break
f.close()

#Searching a record based on roll no


def searchRollno(r):
f=open("student.dat","rb")
flag=False
while True:
try:
rec=pickle.load(f)
if rec['Rollno']==r:
print("Roll no:",rec['Rollno'])
print("Name:",rec['Name'])
print("Marks:",rec["Marks"])
flag=True
except EOFError:
break
if flag==False:
print("No record found")
f.close()

#Marks modification for a roll no


def updateMarks(r,m):
f=open("student.dat","rb")
reclist=[]
while True:
try:
rec=pickle.load(f)
reclist.append(rec)
except EOFError:
break
f.close()
for i in range(len(reclist)):
if reclist[i]["Rollno"]==r:
reclist[i]["Marks"]=m
f=open("student.dat","wb")
for x in reclist:
pickle.dump(x,f)
f.close

#Deleting a record based on Rollno


def deleteRec(r):
f=open("student.dat","rb")
reclist=[]
while True:
try:
rec=pickle.load(f)
reclisy.append(rec)
except EOFError:
break
f.close()
f=open("student.dat","wb")
for x in reclist:
if x["Rollno"]==r:
continue
pickle.dump(x,f)
f.close()

while True:
print("Type 1 to insert rec")
print("Type 2 to display rec")
print("Type 3 to search rec")
print("Type 4 to update rec")
print("Type 5 to delete rec")
choice=int(input("Enter your choice "))
if choice==0:
break
elif choice==1:
insertRec()
elif choice==2:
readRec()
elif choice==3:
r=int(input("Enter a roll no to search "))
searchRollno(r)
elif choice==4:
r=int(input("enter a rollno "))
m=int(input("enter new marks "))
updateMarks(r,m)
elif choice==5:
r=int(input("Enter a rollno "))
deleteRec(r)

OUTPUT

Type 1 to insert rec


Type 2 to display rec
Type 3 to search rec
Type 4 to update rec
Type 5 to delete rec
Enter your choice 1
Enter roll number: 1
Enter name Aaditya
Enter marks 100
Type 1 to insert rec
Type 2 to display rec
Type 3 to search rec
Type 4 to update rec
Type 5 to delete rec
Enter your choice 1
Enter roll number: 102
Enter name: Megha
Enter marks 75

You might also like