Bus Ticket Booking System in Python
PROGRAM:
bus_no = "10"
source = "udumalpet"
destination = "chennai"
total_seats = 10
available_seats = 10
bookings = []
while True:
print("\nMenu")
print("1. Bus Info")
print("2. Book Ticket")
print("3. Show Bookings")
print("4. Exit")
choice = input("Enter your choice: ")
if choice == '1':
print("Bus No:", bus_no)
print("Source:", source)
print("Destination:", destination)
print("Total Seats:", total_seats)
print("Available Seats:", available_seats)
elif choice == '2':
if available_seats > 0:
name = input("Enter your name: ")
seat_number = total_seats - available_seats + 1
bookings.append((seat_number, name))
available_seats -= 1
print("Ticket booked successfully!")
print("Seat No:", seat_number)
print("Name:", name)
else:
print("Sorry, no available seats.")
elif choice == '3':
if not bookings:
print("No bookings yet.")
else:
print("Booked Tickets:")
for seat, name in bookings:
print(f"Seat {seat}: {name}")
print(f"Available Seats: {available_seats}")
elif choice == '4':
print("Thank you! Exiting the program.")
break
else:
print("You have entered an invalid choice. Please try again.")
OUTPUT:
Comments
Post a Comment