Computer Project
Computer Project
Computer Project
NT
I would like to express my special thanks of gratitude to my
Computer Science teacher “Mr.Ashwani Dubey sir” for their
able guidance and support in completing my project.
I would like to extend my gratitude to the principal sir “Mr.
Mathew P.Alancheril Sir” and vice principal ma’am “Mrs.
Nishima Pathak Ma’am” for providing me facility that was
required.
Lastly, I would like to thank my classmates who helped me in
finishing the project within the limited time.
Signature:
Submitted by:
Devansh
Pratap Singh
Class:
12th Science
CERTIFICATE
This is to certify that “DEVANSH PRATAP SINGH” student
of class 12th Science has successfully completed their computer
science Project report file under the guidance of “MR.
ASHWANI DUBEY SIR”.
Signature:
About functions used
i. room() - This function is used to record all data entered by the user like room
number, room price, etc in a binary file.
ii. display() - This function is used to display all the records entered by the user in
the binary file according to a dictionary .
iii. search() - This function is used to search the room entries by entering the room
number, which would make it easier for the user to find any room Entries.
iv. update() - This function is used to update the room Entries, means removing
the entries of the room number entered by the user and entering new room
entries and then it displays the updated room entries.
v. delete() - This function is used to delete the room entries of a particular room
whose number is entered by the user and then shows the record after deduction.
Output
1. Room Enteries
2.Display
3.Search
4.Update
5.Delete
1.Room Enteries
2.Display
3.Search
4.Update
5.Delete
1.Room Enteries
2.Display
3.Search
4.Update
5.Delete
Record Found
1. Room Enteries
2.Display
3.Search
4.Update
5.Delete
1.Room Enteries
2.Display
3.Search
4.Update
5.Delete
d={}
import pickle
import os
def room():
f=open("hotel.dat","wb")
for i in range(N):
print("Enter Room",i+1,"Details")
pickle.dump(d,f)
f.close()
def display():
f=open("hotel.dat","rb")
try:
while True:
r=pickle.load(f)
print(r)
except EOFError:
pass
f.close()
def search():
f=open("hotel.dat","rb")
u=0
try:
while True:
g=pickle.load(f)
if g['rn']==s:
print("Record Found")
print(g)
u=1
break
except EOFError:
pass
if u==0:
f.close()
def update():
f1=open("hotel.dat","rb")
f2=open("temp.dat","wb")
r=int(input("Enter the Room Number to update"))
try:
while True:
g=pickle.load(f1)
if g["rn"]==r:
d={}
pickle.dump(d,f2)
else:
pickle.dump(g,f2)
except EOFError:
pass
f1.close()
f2.close()
os.remove("hotel.dat")
os.rename("temp.dat","hotel.dat")
f=open("hotel.dat","rb")
try:
while True:
r=pickle.load(f)
print(r)
except EOFError:
pass
f.close()
def delete():
f1=open("hotel.dat","rb")
f2=open("temp.dat","wb")
try:
while True:
t=pickle.load(f1)
if t['rn']==r:
pass
else:
pickle.dump(t,f2)
except EOFError:
pass
f1.close()
f2.close()
os.remove("hotel.dat")
os.rename("temp.dat"," hotel.dat")
f=open("hotel.dat","rb")
try:
while True:
r=pickle.load(f)
print(r)
except EOFError:
pass
f.close()
#MAIN PROGRAMME
while True:
print("2.Display")
print("3.Search")
print("4.Update")
print("5.Delete")
if ch==1:
room()
elif ch==2:
display()
elif ch==3:
search()
elif ch==4:
update()
elif ch==5:
delete()
else: