Hotel Management System – Python Pandas and MySQL Project with Source Code
Scroll for Download – Project Code and Report
Project Source Code
import pandas as pd import os def menu(): print("\t\t \"WELCOME TO HOTEL SKYHIGH\"\n") print("\t\t\t+-------------------------------+") print("\t\t\t|1. Booking |\n") print("\t\t\t+-------------------------------+") print("\t\t\t|2. Rooms Info |\n") print("\t\t\t+-------------------------------+") print("\t\t\t|3. Display all Bookings |\n") print("\t\t\t+-------------------------------+") print("\t\t\t|4. Payment |\n") print("\t\t\t+-------------------------------+") print("\t\t\t|5. Update some Info |\n") print("\t\t\t+-------------------------------+") print("\t\t\t|6. Search by Guest_id |\n") print("\t\t\t+-------------------------------+") print("\t\t\t|7. Delete a Booking |\n") print("\t\t\t+-------------------------------+") print("\t\t\t|8.Exit |\n") print("\t\t\t+-------------------------------+") ## For Booking a Room def Booking(): print(' '*45,"Booking Rooms",' '*20) cust_df=pd.read_csv("Guest.csv",index_col=0) while True: print('.'*120) print(' '*40,"Please enter guest details") print('.'*120) custid=int(input("Customer id:")) if len(cust_df.loc[cust_df['Cust_id']==custid])>0: print("Duplicate GUEST ID;Enter a valid GUEST ID") else: break name=input("Name of Guest:") phone_no=int(input("Contact Number:")) add=input("Address:") checkin=input("Date of Check-In:") checkout=input("Expexted Date of Check-Out:") while True: print(' '*45,"SELECT ROOM TYPE") print(' '*40,"1. Standard Non A.C.:Rs.3500") print(' '*40,"2. Standard A.C.:Rs.4000") print(' '*40,"3. 3-Bed Non A.C.:Rs.4500") print(' '*40,"4. 3-Bed A.C.:Rs.5000") print(' '*40,"5. Ultra Deluxe:Rs.6000") roomch=int(input("Enter your preferred room type(1-5):")) if roomch >=1 and roomch <= 5: if roomch==1: room_type="Standard Non A.C." price=3500 elif roomch==2: room_type="Standard A.C." price=4000 elif roomch==3: room_type="3-Bed Non A.C." price=4500 elif roomch==4: room_type="3-Bed A.C." price=5000 elif roomch==5: room_type="Ultra Deluxe" price=6000 break else: print("Sorry,invalid choice!! Please enter again") while True: roomno=int(input("Room no. alloted:")) if len(cust_df.loc[cust_df['Room No.']==roomno])>0: print("Duplicate Room Number;Enter a valid room number") else: break rno=len(cust_df)+1 cust_df.loc[rno,:]=[custid,name,phone_no,add,checkin,checkout,room_type,price,roomno] cust_df.to_csv("Guest.csv",mode='w') print('.'*120) print(' '*40,"ROOM BOOKED SUCCESSFULLY",' '*20) print('.'*120) n=int(input("Press 0 to go back to menu:")) if n==0: menu() else: exit() ## FOR GETTING ROOMS INFORMATION: def Room_info(): print(" HOTEL ROOMS INFORMATION ") print() print('--'*20) print("Standard Non-A.C.") print('--'*20) print("Room amenities include:") print("Room amenities include:") print("1Double Bed\nTelevision \nTelephone\n1 Double-door cupboard\n1 coffee table with 2 sofa") print("Attached washroom with hot/cold water\n") print() print('--'*20) print("Standard A.C.") print("--"*20) print("Room amenities include:") print("1Double Bed\nTelevision \nTelephone\n1 Double-door cupboard\n1 coffee table with 2 sofa") print("Attached washroom with hot/cold water\nWindow/Split A.C.\n") print() print('--'*20) print("3-Bed Non-A.C.") print("--"*20) print("Room amenities include:") print("1Double Bed+1 Single Bed\nTelevision \nTelephone\n1 Triple-door cupboard") print("1 coffee table with 2 sofa\n1 side table") print("Balcony with an accent table with 2 chairs\nAttached washroom with hot/cold water") print() print('--'*20) print("3-Bed A.C.") print("--"*20) print("Room amenities include:") print("1Double Bed+1 Single Bed\nTelevision \nTelephone\n1 Triple-door cupboard") print("1 coffee table with 2 sofa\n1 side table") print("Balcony with an accent table with 2 chairs\nAttached washroom with hot/cold water") print("Window/Split A.C.") print() #Display all the bookings def Display(): print('--'*50) print(" ALL BOOKINGS:") print('--'*50) cust_df=pd.read_csv("Guest.csv",index_col=0) print(cust_df) ## Update any information: def Update(): while True: cust_df=pd.read_csv("Guest.csv",index_col=0) cid=int(input("Enter Guest Id to Update:")) if len(cust_df.loc[cust_df["Cust_id"]==cid])>0: print('--'*50) print("Guest Found") print('--'*50) print("Available information about a guest:") print("1. Name") print("2. Phone No.") print("3. Address") print("4. Check-In") print("5. Check-Out") print("6. Room Type") print("7. Price ") print("8. Room No.") ch=int(input("Enter the field number to be updated:")) field=None if ch==1: field="Name" elif ch==2: field="Phone No." elif ch==3: field="Address" elif ch==4: field="Check-In" elif ch==5: field="Check-Out" elif ch==6: field="Room Type" elif ch==7: field="Price" elif ch==8: field="Room No." chh=input("Enter the new value:") #cust_df.loc[cust_df.loc[cust_df['Cust_id']==cid],field]=chh cust_df.loc[cust_df.loc[cust_df['Cust_id']==cid].index,field]=chh cust_df.to_csv("Guest.csv",mode='w') print("Successfully updated!") y=input("Enter N for discontinuing and Y for continuing:") if y=="N" or y=="n": break else: print("No such Guest ID found!!") ##Search information about a guest: def Search_name(): global patdf cust_df=pd.read_csv("Guest.csv",index_col=0) while True: cname= input("Enter the name of guest to be searched : ") df=cust_df.loc[cust_df['Name'] == cname] if df.empty: print("No such Guest Name found!!") else: print(df) break def Search_cid(): global patdf cust_df=pd.read_csv("Guest.csv",index_col=0) while True: cid=int(input("Enter Guest ID to be searched:")) df=cust_df.loc[cust_df['Cust_id'] == cid] if df.empty: print("No such Guest ID found!!") else: print(df) break ## For deleting an entry: def Delete_booking(): global cust_df cust_df=pd.read_csv("Guest.csv",index_col=0) rno=len(cust_df) while True: cid=int(input("Enter Guest ID to be deleted:")) cust_df.drop(cust_df.loc[cust_df['Cust_id'] == cid].index,inplace=True) if rno==len(cust_df): print("No such Guest ID found!!") else: print("Booking Deleted Successfully") break cust_df.to_csv("Guest.csv",mode='w') ##Displaying the bill: def Payment(): global patdf cust_df=pd.read_csv("Guest.csv",index_col=0) while True: cid=int(input("Enter Guest ID:")) if len(cust_df.loc[cust_df['Cust_id'] == cid])>0: t=cust_df.loc[cust_df["Cust_id"]==cid] a=t.iat[0,4] int_a=int(a[0:2]) #print(int_a) b=t.iat[0,5] int_b=int(b[0:2]) #print(int_b) days=int_b-int_a #print(days) price=t.iat[0,7] bill=price*days print("--"*60) print(" HOTEL SKYHIGH-BILL") print("--"*60) print(" Name of Guest : ",cust_df.loc[cust_df["Cust_id"]==cid].iat[0,1]) print(" Phone No. : ",cust_df.loc[cust_df["Cust_id"]==cid].iat[0,2]) print(" Address : ",cust_df.loc[cust_df["Cust_id"]==cid].iat[0,3]) print(" Date of Check-In : ",cust_df.loc[cust_df["Cust_id"]==cid].iat[0,4]) print(" Date of Check-Out : ",cust_df.loc[cust_df["Cust_id"]==cid].iat[0,5]) print(" Selected room-type : ",cust_df.loc[cust_df["Cust_id"]==cid].iat[0,6]) print(" Price of room per day: Rs.",cust_df.loc[cust_df["Cust_id"]==cid].iat[0,7]) print(" No. of days of stay : ",days) print("--"*60) print(" Total bill : Rs.",bill) print("--"*60) break else: print("No such Guest ID found!!") def getchoice(): while True: os.system("cls") menu() choice = int(input("Kindly enter your choice:")) if choice==1: Booking() elif choice==2: Room_info() elif choice==3: Display() elif choice==4: Payment() elif choice==5: Update() elif choice==6: print("1. By Guest Id") print("2. By Guest Name") ch=input("Enter your search criteria:") if ch=='1': Search_cid() elif ch=='2': Search_name() else: print("Invalid Choice") elif choice==7: Delete_booking() elif choice==8: break else: print("Sorry, Invalid Choice") input("Press enter key to proceed further:") ## main block getchoice()
Python Pandas Project Download PDF