Informatics Practices Project
Kps
Topic: Hotel Management System
Class- XII G
Roll no. 29
Submitted By- Pramesh Khadka
Submitted to- Amjad Sir
Acknowledgement
I would like to take this opportunity to express my gratitude to
those who have been of great assistance in finishing this project
in due course of the stipulated deadline. To begin with, I would
like to thank Principal ma'am, Dr. Anju Mehrotra for her
encouragement and for providing me with all the required
facilities for completing my project.
I extend my heartfelt thanks to Mr. Amjad Khan our Informatics
Practices teacher, who guided me in successful completion of this
project. I take this opportunity to express my deep sense of
gratitude for her invaluable guidance, attitude and immense
motivation, which has sustained my efforts at all stages of this
project work.
I would also acknowledge my gratitude towards my classmates
for having been a source of inspiration and for their patience in
resolving what I couldn't grasp efficiently. I thank them in earnest
for correcting me where I erred and their recommendations. I
thank them all for expanding my interest in the study that is
programming.
At last I would like to thank my parents for constantly pushing me
and motivating me to do my best
Submitted by
Pramesh Khadka
Certificate
This is to certify that this work entitled Hotel
Management System was done under my guidance
and submitted on:_________
For Central Board of Secondary Examination
2024-2025 is the original work of candidate
Signature of the candidate Signature of the Internal Examiner
Signature of the principal Signature of the External Examiner
Code:
The project uses a *CSV file* for data storage, *pandas
DataFrame* for processing,
and *matplotlib* for visualization. It includes menus for insertion,
updation,
deletion, sorting, and searching without using user-defined
functions.
'''
### Python Code for the Hotel Management System
import pandas as pd
import matplotlib.pyplot as plt
import os
# File to store data
file_name = "hotel_data.csv"
# Ensure the file exists
if not os.path.exists(file_name):
df = pd.DataFrame(columns=["Room No", "Guest
Name","Check-in Date",
"Stay Duration", "Room Charges"])
df.to_csv(file_name, index=False)
while True:
print("\n=== Hotel Management System ===")
print("1. Insert Booking")
print("2. Update Booking")
print("3. Delete Booking")
print("4. Search Booking")
print("5. Sort Bookings")
print("6. Display Data & Graph")
print("7. Exit")
choice = int(input("Enter your choice: "))
df = pd.read_csv(file_name)
if choice == 1:
# Insert Booking
room_no = input("Enter Room No: ")
guest_name = input("Enter Guest Name: ")
check_in_date = input("Enter Check-in Date (YYYY-MM-DD):
")
stay_duration = int(input("Enter Stay Duration (days): "))
room_charges = float(input("Enter Room Charges (per day):
"))
df = df.append({"Room No": room_no, "Guest Name":
guest_name, "Check-in Date": check_in_date,
"Stay Duration": stay_duration,
"Room Charges": room_charges},
ignore_index=True)
df.to_csv(file_name, index=False)
print("Booking added successfully.")
elif choice == 2:
# Update Booking
room_no = input("Enter Room No to update: ")
if room_no in df["Room No"].astype(str).values:
while True:
print("Select from the following options:")
print("1. Update Guest Name")
print("2. Update Check-in Date (YYYY-MM-DD)")
print("3. Update Stay Duration (days)")
print("4. Update Room Charges (per day)")
print("5. Exit")
ch = int(input("Enter your choice: "))
if ch==1:
guest_name = input("Enter New Guest Name: ")
df.loc[df["Room No"].astype(str) == room_no, "Guest
Name"] = guest_name
print("Name updated successfully!")
elif ch==2:
check_in_date = input("Enter New Check-in Date
(YYYY-MM-DD): ")
df.loc[df["Room No"].astype(str) == room_no,
"Check-in Date"] = check_in_date
print("check_in_date updated successfully!")
elif ch==3:
stay_duration = int(input("Enter New Stay Duration
(days): "))
df.loc[df["Room No"].astype(str) == room_no, "Stay
Duration"] = stay_duration
print("Stay Duration updated successfully!")
elif ch==4:
room_charges = float(input("Enter New Room
Charges (per day): "))
df.loc[df["Room No"].astype(str) == room_no, "Room
Charges"] = room_charges
print("Room Charges updated successfully!")
elif ch==5:
print("Exiting... Goodbye!")
break
df.to_csv(file_name, index=False)
print("Booking updated successfully.")
else:
print("Invalid choice. Please try again.")
else:
print("Room No not found.")
elif choice == 3:
# Delete Booking
room_no = input("Enter Room No to delete: ")
if room_no in df["Room No"].astype(str).values:
df = df[df["Room No"].astype(str) != room_no]
df.to_csv(file_name, index=False)
print("Booking deleted successfully.")
else:
print("Room No not found.")
elif choice == 4:
# Search Booking
room_no = input("Enter Room No to search: ")
if room_no in df["Room No"].astype(str).values:
print(df[df["Room No"].astype(str) == room_no])
else:
print("Room No not found.")
elif choice == 5:
# Sort Bookings
print("1. Sort by Room No")
print("2. Sort by Guest Name")
print("3. Sort by Check-in Date")
print("4. Sort by Stay Duration")
print("5. Sort by Room Charges")
sort_choice = int(input("Enter your choice: "))
if sort_choice == 1:
print(df.sort_values("Room No"))
elif sort_choice == 2:
print(df.sort_values("Guest Name"))
elif sort_choice == 3:
print(df.sort_values("Check-in Date"))
elif sort_choice == 4:
print(df.sort_values("Stay Duration"))
elif sort_choice == 5:
print(df.sort_values("Room Charges", ascending=False))
else:
print("Invalid choice.")
df.to_csv(file_name, index=False)
elif choice == 6:
# Display Data and Graph
print(df)
print("\n1. Line Chart")
print("2. Bar Graph")
graph_choice = int(input("Enter your choice: "))
if graph_choice == 1:
plt.plot(df["Room No"], df["Room Charges"], marker="o")
plt.title("Room Charges (Line Chart)")
plt.xlabel("Room No")
plt.ylabel("Room Charges")
elif graph_choice == 2:
plt.bar(df["Room No"], df["Room Charges"],
color="skyblue")
plt.title("Room Charges (Bar Graph)")
plt.xlabel("Room No")
plt.ylabel("Room Charges")
else:
print("Invalid choice.")
continue
plt.show()
elif choice == 7:
print("Exiting... Goodbye!")
break
else:
print("Invalid choice. Please try again.")
Examples:
Thank you