Friday, 12 January 2024

Python code on Hotel Management Class - 12

"Hotel Management System in Python - Class 12 Project"





❱ Explanation of this code for Viva or Question's :-

This Python program represents a basic hotel management      system that allows users to perform various operations such as room booking, payment processing, viewing records, and accessing information about available rooms and the restaurant menu. The code utilizes lists to store information about customers, including their names, phone numbers, addresses, check-in and check-out dates, room types, and prices. Random numbers are generated for room numbers and customer IDs to ensure uniqueness.


⚫Here's a breakdown of the main functionalities:


1. **Booking Functionality:**

Users can input their details (name, phone number, address), select check-in and check-out dates, and choose a room type.

Random room numbers and customer IDs are generated and assigned to each booking.

Payment status and room booking status are tracked using flags in the code.


2. **Payment Functionality:**

Users can make payments by entering their phone numbers.

The system calculates the amount based on the selected room type and the number of days stayed.

The user is presented with different payment options, and the payment status is updated upon successful payment.


3. **Record Functionality:**

Displays a record of all bookings with relevant details such as name, phone number, address, check-in, check-out, room type, and total price.


4. **Rooms Info Functionality:**

Provides information about different room types, including facilities and prices.


5. **Restaurant Functionality:**

Displays a menu for the hotel restaurant, including specials for breakfast, lunch, and dinner.

Informs users about possible extra charges for room service.


6. **Home Functionality:**

Acts as the main menu, allowing users to navigate between different functionalities.


The code is structured using functions to modularize different functionalities, making it readable and easy to maintain. It incorporates error handling to ensure that essential information is provided during the booking process. The use of random numbers adds an element of uniqueness to room numbers and customer IDs, avoiding conflicts. Overall, this program provides a simple yet functional representation of a hotel management system in a console-based environment.


The source Code :-


import random

import datetime


name = []

phno = []

add = []

checkin = []

checkout = []

room = []

price = []

rc = []

p = []

roomno = []

custid = []

i = 0


def Booking():

    global i

    print("BOOKING ROOMS")

    print(" ")

    while True:

        n = str(input("Name: "))

        p1 = str(input("Phone No.: "))

        a = str(input("Address: "))

        if n != "" and p1 != "" and a != "":

            name.append(n)

            add.append(a)

            break

        else:

            print(" Name, Phone no. & Address cannot be empty..!!")

    cii = str(input("Check-In (DD/MM/YYYY): "))

    checkin.append(cii)

    coo = str(input("Check-Out (DD/MM/YYYY): "))

    checkout.append(coo)

    print("----SELECT ROOM TYPE----")

    print("1. 1-Bed Non-AC")

    print("2. 1-Bed AC")

    print("3. 2-Bed Non-AC")

    print("4. 2-Bed AC")

    print("Press 0 for Room Prices")

    ch = int(input("->"))

    if ch == 0:

        print("1. 1-Bed Non-AC -  Rs. 4000")

        print("2. 1-Bed AC -        Rs. 4500")

        print("3. 2-Bed Non-AC -  Rs. 5000")

        print("4. 2-Bed AC -        Rs. 5500")

        ch = int(input("->"))

    if ch == 1:

        room.append('1-Bed Non-AC')

        price.append(4000)

    elif ch == 2:

        room.append('1-Bed AC')

        price.append(4500)

    elif ch == 3:

        room.append('2-Bed Non-AC')

        price.append(5000)

    elif ch == 4:

        room.append('2-Bed AC')

        price.append(5500)

    else:

        print("Invalid choice..!!")

        exit()


    rn = random.randrange(40) + 300

    cid = random.randrange(40) + 10

    while rn in roomno or cid in custid:

        rn = random.randrange(60) + 300

        cid = random.randrange(60) + 10

    rc.append(0)

    p.append(0)

    if p1 not in phno:

        phno.append(p1)

    elif p1 in phno:

        for n in range(0, i):

            if p1 == phno[n]:

                if p[n] == 1:

                    phno.append(p1)

    print("  **ROOM BOOKED SUCCESSFULLY**")

    print("Room No. :- "     , rn)

    print("Customer Id :- "  , cid)

    roomno.append(rn)

    custid.append(cid)

    i = i + 1


def Payment():

    ph = str(input("Phone Number:- "))

    global i

    f = 0

    for n in range(0, i):

        if ph == phno[n]:

            if p[n] == 0:

                f = 1

                print("--------------------------------")

                print("               Payment")

                print("--------------------------------")

                print("MODE OF PAYMENT'S")

                print("1- Credit/Debit Card")

                print("2- Paytm/PhonePe")

                print("3- Using UPI")

                print("4- Cash")

                print("--------------------------------")

                x = int(input("-> "))

                

                check_in_date = datetime.datetime.strptime(checkin[n], "%d/%m/%Y")

                check_out_date = datetime.datetime.strptime(checkout[n], "%d/%m/%Y")

                days_stayed = (check_out_date - check_in_date).days

                print("Amount: ", price[n] * days_stayed)

                print("Pay For Urban Lands (1= Yes / 0= No)")

                ch = str(input("->"))

                if ch == '1' :

                    print("*************************************")

                    print("         Hotel Urban Lands")

                    print("*************************************")

                    print("Bill:-")

                    print("--------------------------------")

                    print("Name: ", name[n], "   Phone No.: ", phno[n], "  Address: ", add[n], " ")

                    print("Check-In: ", checkin[n], "   Check-Out: ", checkout[n], "")

                    print("Room Type: ", room[n], "   Room Charges: ", price[n] * days_stayed, "")

                    print("Restaurant Charges:   ", rc[n])

                    print("--------------------------------")

                    print("Total Amount: ", price[n] * days_stayed + rc[n], "")

                    print("--------------------------------")

                    print("Thank You")

                    print("Visit Again! Have Fun (●'◡'●)")

                    print("--------------------------------")

                    p[n] = 1  

                else:

                    print("  Payment has been Made :)")

    if f == 0:

        print("Invalid Customer ID")


def Record():

    if phno != []:

        print(" *** HOTEL RECORD *** ")

        print("+" + "-" * 120 + "+")

        print("| {:<15} | {:<15} | {:<20} | {:<15} | {:<15} | {:<15} | {:<15} |".format("Name", "Phone No.", "Address", "Check-In", "Check-Out", "Room Type", "Price"))

        print("+" + "-" * 120 + "+")

        for n in range(0, i):

            print("| {:<15} | {:<15} | {:<20} | {:<15} | {:<15} | {:<15} | {:<15} |".format(name[n], phno[n], add[n], checkin[n], checkout[n], room[n], price[n] * ((datetime.datetime.strptime(checkout[n], "%d/%m/%Y") - datetime.datetime.strptime(checkin[n], "%d/%m/%Y")).days)))

            print("+" + "-" * 120 + "+")

    else:

        print("No Records Found")



def Rooms_Info():

    print("ROOMS INFORMATION")

    print("---------------------------------------------------------------------")

    print("1. 1-Bed Non-AC:")

    print("- Facilities: Single bed, TV, and attached bathroom")

    print("- Price: Rs. 4000")

    print("---------------------------------------------------------------------")

    print("2. 1-Bed AC:")

    print("- Facilities: Double bed, TV, air conditioning, and attached bathroom")

    print("- Price: Rs. 4500")

    print("---------------------------------------------------------------------")

    print("3. 2-Bed Non-AC:")

    print("- Facilities: Three single beds, TV, and attached bathroom")

    print("- Price: Rs. 5000")

    print("---------------------------------------------------------------------")

    print("4. 2-Bed AC:")

    print("- Facilities: Three single beds, TV, air conditioning, and attached bathroom")

    print("- Price: Rs. 5500")

    print("---------------------------------------------------------------------")

    print("Note: Prices and facilities may vary based on seasonal changes.")

    print("Please contact the reception for more details or any special requests.")

    print("---------------------------------------------------------------------")

    print()


def Restaurant():

    print("---------------------------------------------------------------------")

    print("                              RESTAURANT MENU")

    print("---------------------------------------------------------------------")

    print("                           Welcome to our restaurant!")

    print("---------------------------------------------------------------------")

    print("Today's Specials:")

    print("- Breakfast:   Continental - ₹ 1,132, Indian - ₹ 1,020")

    print("- Lunch:        Italian Pasta - ₹ 1,275, Grilled Chicken - ₹ 1,805")

    print("- Dinner:       Seafood Platter - ₹ 2,500, Steak - ₹ 2,295")

    print("---------------------------------------------------------------------")

    print("*Note: If you order food in your room extra charges may occur.*")

    print("Taxes and service charges may apply.")

    print("Enjoy your meal! (●'◡'●) ")

    print()


def Home():

    while True:

        print("***************************************************")

        print("    (●'◡'●) Welcome To Hotel Urban Land's (●'◡'●)  ")

        print("***************************************************")

        print("1. Booking")

        print("--------------------------------------------")

        print("2. Rooms Info")

        print("--------------------------------------------")

        print("3. Room Service(Menu Card)")

        print("--------------------------------------------")

        print("4. Payment")

        print("--------------------------------------------")

        print("5. Record")

        print("--------------------------------------------")

        print("0. Exit")

        print("***************************************************")

        ch = int(input("->"))

        if ch == 1:

            print(" ")

            Booking()

        elif ch == 2:

            print(" ")

            Rooms_Info()

        elif ch == 3:

            print(" ")

            Restaurant()

        elif ch == 4:

            print(" ")

            Payment()

        elif ch == 5:

            print(" ")

            Record()

        else:

            exit()


Home()



Please make sure that you have written all commands easily


Output :-



















Remember you can edit this code as per your need later 

Gmail :- arkteck1989@gmail.com

email me if you want more of these type of codes















No comments:

Post a Comment

Python code on Hotel Management Class - 12

"Hotel Management System in Python - Class 12 Project" ❱ Explanation of this code for Viva or Question's :- This Python progra...