ACKNOWLEDGEME
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
WELCOME TO HOTEL MANAGEMENT SYSTEM
1. Room Enteries
2.Display
3.Search
4.Update
5.Delete
Enter your CHOICE : 1
TO Fill Room Enteries
Enter Number of Rooms : 3
Enter Room 1 Details
Enter the Room Number 11
Enter Floor Name Alpha
Enter Room Price 2000
Enter Room 2 Details
Enter the Room Number 22
Enter Floor Name Beta
Enter Room Price 1800
Enter Room 3 Details
Enter the Room Number 33
Enter Floor Name Gamma
Enter Room Price 1600
WELCOME TO HOTEL MANAGEMENT SYSTEM
1.Room Enteries
2.Display
3.Search
4.Update
5.Delete
Enter your CHOICE : 2
{'rn': 11, ' Floor Name': ' Alpha', 'Pr': 2000}
{'rn': 22, ' Floor Name': ' Beta', 'Pr': 1800}
{'rn': 33, ' Floor Name': ' Gamma', 'Pr': 1600}
WELCOME TO HOTEL MANAGEMENT SYSTEM
1.Room Enteries
2.Display
3.Search
4.Update
5.Delete
Enter your CHOICE : 3
Enter the Room Number that you want to Search 33
Record Found
{'rn': 33, ' Floor Name': ' Gamma', 'Pr': 1600}
WELCOME TO HOTEL MANAGEMENT SYSTEM
1. Room Enteries
2.Display
3.Search
4.Update
5.Delete
Enter your CHOICE : 4
Enter the Room Number to update 11
Enter New Details of Room
Enter the Room Number 14
Enter the Floor Name Alpha
Enter Room Price 2500
{'rn': 14, 'Floor Name': ' Alpha', 'Pr': 2500}
{'rn': 22, ' Floor Name': ' Beta', 'Pr': 1800}
{'rn': 33, ' Floor Name': ' Gamma', 'Pr': 1600}
WELCOME TO HOTEL MANAGEMENT SYSTEM
1.Room Enteries
2.Display
3.Search
4.Update
5.Delete
Enter your CHOICE : 5
Enter the Room Number to Delete : 22
Record After Deletion
{'rn': 14, 'Floor Name': ' Alpha', 'Pr': 2500}
{'rn': 33, ' Floor Name': ' Gamma', 'Pr': 1600}
Source Code
d={}
import pickle
import os
def room():
f=open("hotel.dat","wb")
N=int(input("Enter Number of Rooms : "))
for i in range(N):
print("Enter Room",i+1,"Details")
d["rn"]=int(input("Enter the Room Number"))
d["Name"]=input("Enter Floor Name")
d["Pr"]=int(input("Enter Room Price"))
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")
s=int(input("Enter the Room Number that you want to Search"))
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:
print("Record not Found")
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={}
print("Enter New Details of Room")
d["rn"]=int(input("Enter the Room Number"))
d["Name"]=input("Enter the Floor Name")
d["Pr"]=int(input("Enter Room Price "))
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")
r=int(input("Enter the Room Number to Delete"))
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")
print("Record After Deletion")
try:
while True:
r=pickle.load(f)
print(r)
except EOFError:
pass
f.close()
#MAIN PROGRAMME
while True:
print("WELCOME TO HOTEL MANAGEMENT SYSTEM")
print("1. Room Enteries")
print("2.Display")
print("3.Search")
print("4.Update")
print("5.Delete")
ch=int(input("Enter your CHOICE : "))
if ch==1:
print("TO Fill Room Enteries")
room()
elif ch==2:
display()
elif ch==3:
search()
elif ch==4:
update()
elif ch==5:
delete()
else:
print("Entered the WRONG CHOICE")