0% found this document useful (0 votes)
6 views35 pages

Cs Project File

The document contains a Python script for managing train bookings, including functions to display seat availability, add and modify train schedules, and book tickets. It interacts with a MySQL database to execute queries for retrieving and updating train and booking information. Key functionalities include showing today's trains, counting trains by location, and finding trains by various criteria.

Uploaded by

adityayadav20084
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views35 pages

Cs Project File

The document contains a Python script for managing train bookings, including functions to display seat availability, add and modify train schedules, and book tickets. It interacts with a MySQL database to execute queries for retrieving and updating train and booking information. Key functionalities include showing today's trains, counting trains by location, and finding trains by various criteria.

Uploaded by

adityayadav20084
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

from datetime import datetime

import [Link]

def draw_general_class_seats(train_id):

occupied_seats = []

query = "select seat_no from bookings where train_id = %s and seat_class='general'"

[Link](query, (train_id,))

records = [Link]()

if len(records) > 0:
for record in records:

occupied_seats.append(record['seat_no'])

print()

print("".ljust(10),end='')

for i in range(1,15):

print(str(i).ljust(10),end='')

print()

for j in "ABC DEF":

print([Link](10),end='')

if j != ' ':

for i in range(1,15):
if str(i)+j in occupied_seats:

print("X".ljust(10),end='')

else:

print(" ".ljust(10), end='')


print()

print()

def draw_nonac_class_seats(train_id):

occupied_seats = []
query = "select seat_no from bookings where train_id = %s and seat_class='nonac'"

[Link](query, (train_id,))

records = [Link]()

if len(records) > 0:

for record in records:

occupied_seats.append(record['seat_no'])

print()

print("".ljust(10),end='')
for i in range(16,25):

print(str(i).ljust(10),end='')

print()

for j in "ABC DEF":

print([Link](10),end='')

if j != ' ':

for i in range(16,25):

if str(i)+j in occupied_seats:

print("X".ljust(10),end='')

else:

print(" ".ljust(10), end='')


print()

print()

def draw_ac_class_seats(train_id):

occupied_seats = []
query = "select seat_no from bookings where train_id = %s and seat_class='ac'"

[Link](query, (train_id,))

records = [Link]()

if len(records) > 0:
for record in records:

occupied_seats.append(record['seat_no'])

print()

print("".ljust(10),end='')

for i in range(26,40):

print(str(i).ljust(10),end='')

print()

for j in "ABC DEF":


print([Link](10),end='')

if j != ' ':

for i in range(26,40):

if str(i)+j in occupied_seats:

print("X".ljust(10),end='')

else:

print(" ".ljust(10), end='')

print()

print()

def add_train():

train_number = input("Enter the train number: ")


starting_location = input("Enter the starting location: ")

end_location = input("Enter the end location: ")

departure_time = [Link](input("Enter the time of departure (DD-MM-YYYY h:m):


"), "%d-%m-%Y %H:%M")
arrival_time = [Link](input("Enter the time of arrival (DD-MM-YYYY h:m): "),
"%d-%m-%Y %H:%M")

query = "insert into trains(train_number, starting_location, end_location, departure_time,


arrival_time) " \

"values(%s,%s,%s,%s,%s)"
[Link](query,(train_number, starting_location, end_location, departure_time,
arrival_time))

[Link]()

print("Train Scheduled.")

def show_todays_trains():

query = "select * from trains where date(departure_time) = curdate()"

[Link](query)

records = [Link]()
if len(records) == 0:

print("No such trains.")

else:

for key in records[0]:

print([Link](20),end='')

print()

print("-"*150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

def show_trains_scheduled_for_date():
departure_date = input("Enter the departure date (DD-MM-YYYY): ")

departure_date = [Link](departure_date, "%d-%m-%Y")

query = "select * from trains where date(departure_time) =


'{0}'".format(departure_date.strftime("%Y-%m-%d"))

[Link](query)

records = [Link]()

if len(records) == 0:
print("No such trains.")
else:

for key in records[0]:

print([Link](20),end='')

print()

print("-"*150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')
print()

def show_trains_scheduled_in_time_interval():

date1 = input("Enter the start time (DD-MM-YYYY h:m): ")

date1 = [Link](date1, "%d-%m-%Y %H:%M")

date2 = input("Enter the end time (DD-MM-YYYY h:m): ")

date2 = [Link](date2, "%d-%m-%Y %H:%M")

query = "select * from trains where departure_time between '{0}' and


'{1}'".format([Link]("%Y-%m-%d %H:%M"), [Link]("%Y-%m-%d %H:%M"))

[Link](query)

records = [Link]()

if len(records) == 0:

print("No such trains.")


else:

for key in records[0]:

print([Link](20),end='')
print()

print("-"*150)

for record in records:

for key in record:


print(str(record[key])[0:20].ljust(20), end='')

print()

def show_trains_ending_in_time_interval():

date1 = input("Enter the start time (DD-MM-YYYY h:m): ")

date1 = [Link](date1, "%d-%m-%Y %H:%M")

date2 = input("Enter the end time (DD-MM-YYYY h:m): ")

date2 = [Link](date2, "%d-%m-%Y %H:%M")

query = "select * from trains where arrival_time between '{0}' and


'{1}'".format([Link]("%Y-%m-%d %H:%M"), [Link]("%Y-%m-%d %H:%M"))

[Link](query)

records = [Link]()

if len(records) == 0:

print("No such trains.")

else:

for key in records[0]:

print([Link](20),end='')

print()

print("-"*150)

for record in records:

for key in record:


print(str(record[key])[0:20].ljust(20), end='')

print()

def show_trains_by_starting_location():
location = input("Enter the location: ")

departure_date = input("Enter the departure date (DD-MM-YYYY): ")

departure_date = [Link](departure_date, "%d-%m-%Y")

query = "select * from trains where date(departure_time) = '{0}' and


starting_location='{1}'".format(departure_date.strftime("%Y-%m-%d"),location)
[Link](query)

records = [Link]()

if len(records) == 0:

print("No such trains scheduled on specified date.")

else:

for key in records[0]:

print([Link](20),end='')

print()
print("-"*150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

def count_trains_by_starting_location():

location = input("Enter the starting location: ")

departure_date = input("Enter the departure date (DD-MM-YYYY): ")

departure_date = [Link](departure_date, "%d-%m-%Y")

query = "select count(*) as train_count from trains where date(departure_time) = '{0}' and
starting_location='{1}'".format(departure_date.strftime("%Y-%m-%d"),location)

[Link](query)
records = [Link]()

print("Number of such trains: " , records[0]['train_count'])

print()
def count_trains_by_ending_location():

location = input("Enter the ending location: ")

departure_date = input("Enter the departure date (DD-MM-YYYY): ")

departure_date = [Link](departure_date, "%d-%m-%Y")


query = "select count(*) as train_count from trains where date(departure_time) = '{0}' and
end_location='{1}'".format(departure_date.strftime("%Y-%m-%d"),location)

[Link](query)

records = [Link]()

print("Number of such trains: " , records[0]['train_count'])

print()

def show_trains_by_ending_location():

departure_date = input("Enter the departure date (DD-MM-YYYY): ")


departure_date = [Link](departure_date, "%d-%m-%Y")

location = input("Enter the ending location: ")

query = "select * from trains where date(departure_time) = '{0}' and


end_location='{1}'".format(departure_date.strftime("%Y-%m-%d"),location)

[Link](query)

records = [Link]()

if len(records) == 0:

print("No such trains scheduled on specified date.")

else:

for key in records[0]:

print([Link](20),end='')

print()
print("-"*150)

for record in records:

for key in record:


print(str(record[key])[0:20].ljust(20), end='')

print()

def find_train_by_id():

id = int(input("Enter the train id: "))


query = "select * from trains where id = %s"
[Link](query,(id,))

records = [Link]()

record = None

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')
print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

def find_train_by_train_number():

train_number = input("Enter the train number: ")

query = "select * from trains where train_number = %s"

[Link](query,(train_number,))

records = [Link]()
record = None

if len(records) == 0:

print("No matching record")

else:
for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)
for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

return record

def find_earliest_train_to_location():

location = input("Enter the ending location: ")

query = "select * from trains where end_location = %s order by departure_time limit 1"
[Link](query,(location,))

records = [Link]()

record = None

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:


for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

return record
def modify_train_details():

id = int(input("Enter the train id: "))

query = "select * from trains where id = %s"

[Link](query,(id,))
records = [Link]()

record = None

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()
print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

if record is not None:

query = "update trains set"

print("Input new values (leave blank to keep previous value)")

train_number = input("Enter the new train number: ")

if len(train_number) > 0:

query += " train_number='{0}',".format(train_number)


starting_location = input("Enter the new starting location: ")

if len(starting_location) > 0:

query += " starting_location='{0}',".format(starting_location)

end_location = input("Enter the new end location: ")


if len(end_location) > 0:

query += " end_location='{0}',".format(end_location)

departure_time = input("Enter the new departure time (DD-MM-YYYY h:m): ")

if len(departure_time) > 0:
departure_time = [Link](departure_time,"%d-%m-%Y %H:%M")

query += " departure_time='{0}',".format(departure_time.strftime("%Y-%m-%d


%H:%M"))

arrival_time = input("Enter the new arrival time (DD-MM-YYYY h:m): ")

if len(arrival_time) > 0:

arrival_time = [Link](arrival_time,"%d-%m-%Y %H:%M")

query += " arrival_time='{0}',".format(arrival_time.strftime("%Y-%m-%d %H:%M"))

query = query[0:-1] + " where id={0}".format(record['id'])


confirm = input("Confirm Update (Y/N): ").lower()

if confirm == 'y':

[Link](query)

[Link]()

print("Operation Successful")

else:

print("Operation Cancelled")

def delete_train():

id = int(input("Enter the train id: "))

query = "select * from trains where id = %s"

[Link](query,(id,))

records = [Link]()
record = None

if len(records) == 0:

print("No matching record")


else:

for key in records[0]:

print([Link](20), end='')

print()
print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

if record is not None:

query = "delete from trains where id=%s"

confirm = input("Confirm Delete (Y/N): ").lower()


if confirm == 'y':

[Link](query,(record['id'],))

[Link]()

print("Operation Successful")

else:

print("Operation Cancelled")

def book_ticket():

id = int(input("Enter the train id: "))

query = "select * from trains where id = %s"

[Link](query,(id,))

records = [Link]()
record = None

if len(records) == 0:

print("No matching record")

else:
for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)
for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record

if train is not None:

name = input("Enter customer name: ")

gender = input("Enter the gender: ")


age = int(input("Enter the age: "))

id_details = input("Enter the the id card name and number: ")

seat_class = input("Enter the class (ac, general, nonac): ").lower()

if seat_class == "general":

draw_general_class_seats(train['id'])

elif seat_class == "nonac":

draw_nonac_class_seats(train['id'])

elif seat_class == "ac":

draw_ac_class_seats(train['id'])

seat_no = input("Enter the seat number (Ex. 10A): ")

query = "insert into bookings(train_id, name, gender, age, id_details, seat_class, seat_no) " \
"values(%s,%s,%s,%s,%s,%s,%s)"

[Link](query,(train['id'],name,gender,age,id_details,seat_class,seat_no))

[Link]()

print("Ticket Booked. Please note the ticket number: ", [Link])


def find_booking_by_id():

id = int(input("Enter the booking id: "))

query = "select * from bookings where id = %s"

[Link](query,(id,))
records = [Link]()

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)
for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

def show_bookings_of_train():

id = int(input("Enter the train id: "))

query = "select * from trains where id = %s"

[Link](query, (id,))

records = [Link]()

record = None

if len(records) == 0:
print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')
print()

print("-" * 150)

for record in records:

for key in record:


print(str(record[key])[0:20].ljust(20), end='')

print()

train = record

if train is not None:

query = "select * from bookings where train_id = %s"

[Link](query,(train['id'],))

records = [Link]()

if len(records) == 0:
print("No bookings yet.")

else:

print()

print(len(records) , " bookings found: ")

for key in records[0]:

print([Link](20),end='')

print()

print("-"*150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')
print()

def modify_booking_details():

id = int(input("Enter the booking id: "))

query = "select * from bookings where id = %s"


[Link](query, (id,))

records = [Link]()

record = None

if len(records) == 0:
print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:

for key in record:


print(str(record[key])[0:20].ljust(20), end='')

print()

if record is not None:

query = "update bookings set"

print("Input new values (leave blank to keep previous value)")

name = input("Enter the new name: ")

if len(name) > 0:

query += " name='{0}',".format(name)

gender = input("Enter the new gender: ")

if len(gender) > 0:

query += " gender='{0}',".format(gender)


age = input("Enter the new age: ")

if len(age) > 0:

query += " age={0},".format(age)

id_details = input("Enter the id details: ")


if len(id_details) > 0:

query += " id_details='{0}',".format(id_details)

seat_class = input("Enter the new seat class: ")

if len(seat_class) > 0:
query += " seat_class='{0}',".format(seat_class)

seat_no = input("Enter the new seat no: ")

if len(seat_no) > 0:

query += " seat_no='{0}',".format(seat_no)

boarding_time = input("Enter the new boarding time (DD-MM-YYYY h:m): ")

if len(boarding_time) > 0:

boarding_time = [Link](boarding_time,"%d-%m-%Y %H:%M")

query += " boarding_time='{0}',".format(boarding_time.strftime("%Y-%m-%d


%H:%M"))

query = query[0:-1] + " where id={0}".format(record['id'])

confirm = input("Confirm Update (Y/N): ").lower()

if confirm == 'y':

[Link](query)

[Link]()

print("Operation Successful")

else:

print("Operation Cancelled")

def delete_booking():

id = int(input("Enter the booking id: "))

query = "select * from bookings where id = %s"


[Link](query, (id,))

records = [Link]()

record = None
if len(records) == 0:

print("No matching record")

else:

for key in records[0]:


print([Link](20), end='')

print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

if record is not None:


query = "delete from bookings where id=%s"

confirm = input("Confirm Delete (Y/N): ").lower()

if confirm == 'y':

[Link](query,(record['id'],))

[Link]()

print("Operation Successful")

else:

print("Operation Cancelled")

def passenger_boarding():

id = int(input("Enter the booking id: "))

query = "select * from bookings where id = %s"


[Link](query, (id,))

records = [Link]()

record = None

if len(records) == 0:
print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')
print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

if record is not None:

boarding_time = [Link]()
query = "update bookings set boarding_time=%s where id=%s"

confirm = input("Confirm Update (Y/N): ").lower()

if confirm == 'y':

[Link](query,(boarding_time, record['id']))

[Link]()

print("Operation Successful")

else:

print("Operation Cancelled")

def find_bookings_by_person_name():

id = input("Enter the train id: ")

query = "select * from trains where id = %s"


[Link](query, (id,))

records = [Link]()

record = None

if len(records) == 0:
print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')
print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record

name = input("Enter full or part of the person name: ")


query = "select * from bookings where name like '%{0}%' and
train_id={1}".format(name,train['id'])

[Link](query)

records = [Link]()

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:


for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()
def find_bookings_grouped_by_gender():

id = input("Enter the train id: ")

query = "select * from trains where id = %s"

[Link](query, (id,))
records = [Link]()

record = None

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()
print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record

query = "select gender, count(*) as person_count from bookings where train_id={0} group
by gender".format(train['id'])

[Link](query)

records = [Link]()

if len(records) == 0:

print("No matching record")


else:

for key in records[0]:

print([Link](20), end='')
print()

print("-" * 150)

for record in records:

for key in record:


print(str(record[key])[0:20].ljust(20), end='')

print()

def find_bookings_by_id_details():

id = input("Enter the train id: ")

query = "select * from trains where id = %s"

[Link](query, (id,))

records = [Link]()

record = None
if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()
train = record

id_details = input("Enter full or part of the id details: ")

query = "select * from bookings where id_details like '%{0}%' and


train_id={1}".format(id_details,train['id'])
[Link](query)

records = [Link]()

if len(records) == 0:

print("No matching record")


else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')
print()

def find_bookings_grouped_by_seat_class():

id = input("Enter the train id: ")

query = "select * from trains where id = %s"

[Link](query, (id,))

records = [Link]()

record = None

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:


print([Link](20), end='')

print()

print("-" * 150)

for record in records:


for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record
query = "select seat_class, count(*) as person_count from bookings where train_id={0}
group by seat_class".format(train['id'])

[Link](query)

records = [Link]()

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:


print([Link](20), end='')

print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

def find_bookings_who_missed_boarding():

id = int(input("Enter the train id: "))

query = "select * from trains where id = %s"

[Link](query, (id,))

records = [Link]()
record = None

if len(records) == 0:

print("No matching record")


else:

for key in records[0]:

print([Link](20), end='')

print()
print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record

query = "select * from bookings where boarding_time is null and


train_id={0}".format(train['id'])
[Link](query)

records = [Link]()

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')
print()

def find_list_of_senior_citizen():

id = int(input("Enter the train id: "))


query = "select * from trains where id = %s"

[Link](query, (id,))

records = [Link]()

record = None
if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:


for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record

query = "select * from bookings where age>=60 and train_id={0}".format(train['id'])

[Link](query)

records = [Link]()

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:


print([Link](20), end='')

print()

print("-" * 150)

for record in records:


for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

def count_number_of_passengers():
id = int(input("Enter the train id: "))

query = "select * from trains where id = %s"

[Link](query, (id,))

records = [Link]()

record = None

if len(records) == 0:

print("No matching record")

else:
for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record

query = "select count(*) as person_count from bookings where


train_id={0}".format(train['id'])

[Link](query)
records = [Link]()

if len(records) == 0:

print("No matching record")


else:

for key in records[0]:

print([Link](20), end='')

print()
print("-" * 150)

for record in records:

for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

def draw_seat_chart():

id = int(input("Enter the train id: "))

query = "select * from trains where id = %s"


[Link](query, (id,))

records = [Link]()

record = None

if len(records) == 0:

print("No matching record")

else:

for key in records[0]:

print([Link](20), end='')

print()

print("-" * 150)

for record in records:


for key in record:

print(str(record[key])[0:20].ljust(20), end='')

print()

train = record
draw_general_class_seats(train['id'])

draw_nonac_class_seats(train['id'])

draw_ac_class_seats(train['id'])

if __name__ == '__main__':
db = [Link](

host="localhost",

user="root",

password="root",

crsr = [Link](dictionary=True,buffered=True)

[Link]("create database if not exists train")

[Link]("use train")
[Link]("create table if not exists trains("

"id int primary key auto_increment,"

"train_number varchar(10) not null,"

"starting_location varchar(20) not null,"

"end_location varchar(20) not null,"

"departure_time datetime not null,"

"arrival_time datetime not null"

")")

[Link]("create table if not exists bookings("

"id int primary key auto_increment,"

"train_id int not null,"


"name varchar(20) not null,"

"gender varchar(10) not null,"

"age int not null,"

"id_details varchar(50) not null,"


"seat_class varchar(20) not null,"

"seat_no varchar(5) not null,"

"boarding_time datetime"

")")
while True:

print()

print("-"*50)

print("----Trains Management System-----")

print("----Main Menu----")

print("1. Manage Train Schedules")

print("2. Manage Bookings")

print("0. Exit")
print("-"*50)

print()

choice = int(input("Enter the choice: "))

if choice == 1:

while True:

print()

print("-" * 50)

print("----Train Schedule Management----")

print("1. Schedule a train")

print("2. Show Trains Scheduled For Today")

print("3. Find train by id")


print("4. Edit train record")

print("5. Delete train record")

print("6. Show trains scheduled for specific date")

print("7. Show trains by starting location")


print("8. Show trains trains by ending location")

print("9. Show trains by departure time interval")

print("10. Show trains by arrival time interval")

print("11. Count number of trains departing from location")


print("12. Count number of trains arriving at a location")

print("13. Find the earliest train to a location")

print("14. Find trains by train number")

print("0. Go Back To Main Menu")

print("-" * 50)

print()

choice = int(input("Enter the choice: "))

if choice == 1:
add_train()

elif choice == 2:

show_todays_trains()

elif choice == 3:

find_train_by_id()

elif choice == 4:

modify_train_details()

elif choice == 5:

delete_train()

elif choice == 6:

show_trains_scheduled_for_date()
elif choice == 7:

show_trains_by_starting_location()

elif choice == 8:

show_trains_by_ending_location()
elif choice == 9: show_trains_scheduled_in_time_interval()

elif choice == 10: show_trains_ending_in_time_interval()

elif choice == 11:

count_trains_by_starting_location()
elif choice == 12:

count_trains_by_ending_location()

elif choice == 13:

find_earliest_train_to_location()

elif choice == 14:

find_train_by_train_number()

elif choice == 0:

break
else:

print("Invalid choice")

elif choice == 2:

while True:

print()

print("-" * 50)

print("----Booking Management----")

print("1. Book a ticket")

print("2. Show Bookings of a train")

print("3. Find booking record by id")

print("4. Edit booking record")


print("5. Delete booking record")

print("6. Passenger boarding")

print("7. Find Bookings by person name")

print("8. Show Number of Passengers grouped by gender")


print("9. Find Bookings by id details")

print("10. Show Number of Passengers grouped by seat class")

print("11. Show train seat chart")

print("12. Show list of customers who did not board")


print("13. Show list of senior citizens on train")

print("14. Count number of Passengers in a train")

print("0. Go Back To Main Menu")

print("-" * 50)

print()

choice = int(input("Enter the choice: "))

if choice == 1:

book_ticket()
elif choice == 2:

show_bookings_of_train()

elif choice == 3:

find_booking_by_id()

elif choice == 4:

modify_booking_details()

elif choice == 5:

delete_booking()

elif choice == 6:

passenger_boarding()

elif choice == 7:
find_bookings_by_person_name()

elif choice == 8:

find_bookings_grouped_by_gender()

elif choice == 9:
find_bookings_by_id_details()

elif choice == 10:

find_bookings_grouped_by_seat_class()

elif choice == 11:


draw_seat_chart()

elif choice == 12:

find_bookings_who_missed_boarding()

elif choice == 13:

find_list_of_senior_citizen()

elif choice == 14:

count_number_of_passengers()

elif choice == 0:
break

else:

print("Invalid choice")

elif choice == 0:

break

else:

print("Invalid Choice!")

[Link]()

print("Thank you!")

You might also like