kartik project cs
kartik project cs
Principal Department of
Mrs. Ishwari Sharma Computer Science
Mrs. Soubhagya G H
External examiner
INDEX
1. Acknowledgement
2. System specification
3. About Python
4. Modules and Menus
5. Source Code
6. Output
7. Pros/Cons
8. Bibliography
Acknowledgement
I would like to express my sincere appreciation to
all those who contributed to the success of this
computer science project. A special thanks goes to
my computer teacher Mrs. Soubhagya GH, for her
invaluable guidance, support, and expertise
throughout the entire project.
I extend my sincere gratitude to our principal, Mrs.
Ishwari Sharma, for her unwavering support and
leadership.
I am grateful to my school for providing resources,
tools, or assistance that proved essential to the
completion of this project.
This project would not have been possible without
the collective effort and support of these
individuals, and I am truly thankful for their
contributions.
System Specifications
General information:
• System Type: x64-based PC
• OS Name Microsoft Windows 11 Home
SingleLanguage Processor:
• Processor 11th Gen Intel(R) Core(TM)
i31115G4 @ 3.00GHz, 2995 Mhz, 2 Core(s), 4
Logical Processor(s)
Memory and Storage:
• Installed RAM:8GB
• Primary Storage type: SSD
• Primary Storage Capacity: 170GB
Programming Language:
Python(Spyder IDE)
MySQL
Python:
Python is a high-level, versatile and dynamically-typed
programming language known for its readability and
simplicity. Created by Guido van Rossum and first
released in 1991, Python emphasizes code readability and
ease of use, making it an excellent choice for beginners and
experienced developers alike. It supports multiple
programming paradigms, including procedural, object-
oriented, and functional programming.
add_guest()
This function allows the user to input guest details (name,
room number, and phone number) and appends this
information to a file named guests.txt.
view_guests()
This function reads the guests.txt file and displays the
details of all guests. If the file is not found, it informs the
user that no guests are present.
search_guest()
This function prompts the user to enter a guest's name and
searches for that guest in the guests.txt file. If found, it
displays the guest's details; otherwise, it informs the user
that the guest was not found.
delete_guest()
This function allows the user to delete a guest's
information by name. It reads all guests from the file,
excluding the specified guest, and rewrites the file without
that guest's entry.
update_guest()
This function enables the user to update a guest's room
number and phone number. It searches for the guest by
name and modifies the details accordingly.
main()
This function serves as the main menu for the application.
It presents the user with options to add, view, search,
delete, or update guest information. The loop continues
until the user chooses to exit.
SOURCE CODE:
def add_guest():
name = input("Enter guest name: ")
room_number = input("Enter room number: ")
phone_number = input("Enter phone number: ")
def view_guests():
try:
with open("guests.txt", 'r') as file:
guests = file.readlines()
for guest in guests:
name, room_number, phone_number = guest.strip().split(',')
print(f"Name: {name}, Room Number: {room_number}, Phone Number:
{phone_number}")
except FileNotFoundError:
print("No guests in the hotel.")
def search_guest():
name = input("Enter guest name: ")
try:
with open("guests.txt", 'r') as file:
guests = file.readlines()
for guest in guests:
guest_name, room_number, phone_number = guest.strip().split(',')
if guest_name.lower() == name.lower():
print(f"Name: {guest_name}, Room Number: {room_number}, Phone
Number: {phone_number}")
return
print("Guest not found.")
except FileNotFoundError:
print("No guests in the hotel.")
def delete_guest():
name = input("Enter guest name: ")
try:
with open("guests.txt", 'r') as file:
guests = file.readlines()
with open("guests.txt", 'w') as file:
for guest in guests:
guest_name, room_number, phone_number = guest.strip().split(',')
if guest_name.lower() != name.lower():
file.write(guest)
print("Guest deleted successfully.")
except FileNotFoundError:
print("No guests in the hotel.")
def update_guest():
name = input("Enter guest name: ")
try:
with open("guests.txt", 'r') as file:
guests = file.readlines()
with open("guests.txt", 'w') as file:
for guest in guests:
guest_name, room_number, phone_number = guest.strip().split(',')
if guest_name.lower() == name.lower():
room_number = input("Enter new room number: ")
phone_number = input("Enter new phone number: ")
file.write(f"{name},{room_number},{phone_number}\n")
else:
file.write(guest)
print("Guest updated successfully.")
except FileNotFoundError:
print("No guests in the hotel.")
def main():
while True:
print("\nHotel Management Menu:")
print("1. Add Guest")
print("2. View Guests")
print("3. Search Guest")
print("4. Delete Guest")
print("5. Update Guest")
print("6. Exit")
if choice == '1':
add_guest()
elif choice == '2':
view_guests()
elif choice == '3':
search_guest()
elif choice == '4':
delete_guest()
elif choice == '5':
update_guest()
elif choice == '6':
break
else:
print("Invalid choice. Please choose a valid option.")
main()
Output:
Add a guest:
Delete a Guest:
Update a guest:
Updated records:
EXIT:
PROS AND CONS:
Pros:
1. Simplicity: The code is straightforward and easy to understand,
making it accessible for beginners learning Python and file handling.
2. Functionality: The application provides essential functionalities for
managing guest information, including adding, viewing, searching, deleting,
and updating guest records.
3. File Handling: The use of text files for data storage is a simple method
for persistent data management, allowing for easy access and
updates.
4. User Interaction: The program interacts with users through a console-
based menu, making it user-friendly and easy to navigate.
5. Error Handling: Basic error handling is implemented (e.g., checking if the
guest file exists), which helps prevent crashes when the file is not found.
6. Modularity: The use of functions for each operation promotes code
reusability and makes it easier to maintain or expand in the future.
Cons:
1. Data Integrity: The current implementation does not enforce any data
validation. For example, it does not check if the phone number is in a
valid format or if the room number is valid.
2. Concurrency Issues: The application does not handle concurrent access to
the guests.txt file, which could lead to data corruption if multiple instances
of the program are run simultaneously.
3. Limited Search Functionality: The search function only allows searching by
name, which may not be sufficient in larger datasets. Implementing more
robust search options (e.g., by room number or phone number) would
enhance usability.
4. No Backup or Recovery Mechanism: If the guests.txt file is
accidentally deleted or corrupted, all data would be lost.
Implementing backup functionality would mitigate this risk.
5. Scalability: As the number of guests increases, the performance of the
application may degrade since it reads the entire file into memory for
operations like search, update, and delete. Using a database would be
more efficient for larger datasets.
6. User Experience: The console interface is basic and lacks graphical user
interface (GUI) elements. A GUI would improve user experience
significantly, especially for users unfamiliar with command-line
operations.
Conclusion
The Hotel Management System project demonstrates fundamental
programming concepts and file handling in Python. While it has several
advantages, such as simplicity and basic functionality, there are also
notable limitations that could be addressed to enhance the application's
robustness and usability. Future improvements could include data
validation, a graphical user interface, and the use of a database for better
data management.
Bibliography:
• NCERT class 12 Computer Science
• Computer Science with Python by Sumita
Arora.
• www.programiz.com
• Internet