Ankit Doc
Ankit Doc
COLUMBUS SCHOOL
TOPIC: PHONE
Acknowledgement
I thank my Computer Science teacher Ms. Shweta Siddha for guidance and support. I
would also like to thank my parents and my friends for encouraging me during the course
of this project. Finally I would like to thank CBSE for giving me the opportunity to
undertake this project.
Certificate
This is to certify Ankit Negi of Class XII A, St. Columbus School, Dayal Bagh, Faridabad
has successfully completed this project in computer practical as prescribed by CBSE in the
year 2024-2025.
Date: 18/11/2024
CODINGS
import pickle
import sys
from os import remove, rename,path
def display(x):
print("\tPRODUCT MODEL - ", x['p model'])
print("\tPRODUCT NUMBER - ",x['p number'])
print("\tIMEI - ",x['imei'])
print("\tSTORAGE - ",x['storage'])
print("\tRAM - ",x['ram'])
print("\tPRICE - ",x['price'])
print("\tBATTERY CAPACITY - ",x['battery'])
print("\n\n")
def input_rec():
if path.exists("phone.dat"):
print("File Found")
f=open("phone.dat","ab")
else:
print("File Not Found")
print("Creating a file ..")
f=open("phone.dat","ab")
m=input("ENTER PRODUCT MODEL - ")
n=input("ENTER PRODUCT NUMBER - ")
i=eval(input("ENTER IMEI NUMBER - "))
s=input("ENTER INTERNAL STORAGE - ")
r=input("ENTER RAM - ")
p=eval(input("ENTER PRICE - "))
b=input("ENTER BATTERY CAPACITY - ")
pickle.dump(rec,f)
print("Record Inserted")
f.close()
def output_rec():
f = open("phone.dat","rb")
try:
while True:
x = pickle.load(f)
display(x)
except:
f.close()
def search_model():
fo=0
f=open("phone.dat","rb")
md=input("Enter the model to be searched - ")
try:
while True:
x=pickle.load(f)
if x['p model']==md:
display(x)
fo=1
except:
f.close()
if fo==0:
print("Record not found")
def search_ram():
fm=0
f=open("phone.dat","rb")
rm=input("Enter the ram you want in your phone - ")
try:
while True:
x=pickle.load(f)
if x['ram']==rm:
display(x)
fm=1
except:
f.close()
if fm==0:
print("Record not found")
def search_battery():
fn=0
f=open("phone.dat","rb")
rb=input("Enter the battery you want in your phone - ")
try:
while True:
x=pickle.load(f)
if x['battery']==rb:
display(x)
fn=1
except:
f.close()
if fn==0:
print("Record not found")
def modify_rec():
fr=open("phone.dat","rb")
fw=open("new_phone.dat","wb")
mn=input("Enter the model name to be updated - ")
try:
while True:
x=pickle.load(fr)
if x['p model']==mn:
x['price']=eval(input("ENTER PRICE - "))
pickle.dump(x,fw)
except:
print("Records updated")
fr.close()
fw.close()
remove('phone.dat')
rename('new_phone.dat','phone.dat')
def delete_rec():
fx=open("phone.dat","rb")
fz=open("new_phone.dat","wb")
mn=input("Enter the model name to be deleted - ")
fou=0
try:
while True:
x=pickle.load(f)
if x['p model']==mn:
fou=1
else:
pickle.dump(x,fz)
except:
fx.close()
fz.close()
if fou==1:
print("Records deleted")
remove('phone.dat')
rename('new_phone.dat','phone.dat')
r='y'
while r.lower()=='y':
print("\n\n")
print("MAX STORES")
print("1. Enter New Record")
print("2. Display All Records")
print("3. Search Your Records")
print("4. Update Your Record")
print("5. Delete Any Record")