Computer Project
Computer Project
Computer Project
VIGYAN VIHAR
SESSION 2022-23
XII E
Roll no: 32
CERTIFICATE
This is to certify that this practical file is
CBSE.
Shilpi Singh
Date:21/12/2022
ACKNOWLEDGEMET
I would like to express our sincere gratitude to my
computer science teacher Ms. Shilpi Singh for her vital
support, guidance and encouragement without which
this practical file would not come forth from my side,
she helped me completing the file by giving me ideas
thoughts and made this project easy and accurate. I
wish to thank my principal who inspired me to go my
own way without which I would be unable to complete
my file
Naveen Yadav
XII E
Roll no 32
INDEX
Introduction 1
Configuration 2
Python code 3
Out put 4
INTRODUCTION
Railway management
python 3.11
Python code
# Constants
# Train class
class Train:
self.train_id = train_id
self.name = name
self.source = source
self.destination = destination
self.tickets_available = tickets_available
def __str__(self):
trains = []
# Function to display the schedules and ticket availability for all trains
def display_schedules():
if not trains:
else:
print(train)
found_trains = []
found_trains.append(train)
return found_trains
train = None
for t in trains:
if t.train_id == train_id:
train = t
break
if not train:
return
return
# Purchase tickets
train.tickets_available -= num_tickets
def view_ticket_sales_report():
total_tickets_sold = 0
total_revenue = 0
train = None
for t in trains:
if t.train_id == train_id:
train = t
break
if not train:
return
# Cancel tickets
train.tickets_available += num_tickets
Train schedules:
Express: 7:00 AM, 9:00 AM, 11:00 AM, 1:00 PM, 3:00 PM
Local: 8:00 AM, 10:00 AM, 12:00 PM, 2:00 PM, 4:00 PM
TICKET AVAILABILITY
Train ID: 1, Name: Mumbai Express, Source: Mumbai, Destination: Delhi, Tickets available:
500
Train ID: 2, Name: Delhi Duronto, Source: Delhi, Destination: Chennai, Tickets available: 600
Train ID: 3, Name: Chennai Mail, Source: Chennai, Destination: Mumbai, Tickets available:
450
print(found_trains)
[Train ID: 2, Name: Delhi Duronto, Source: Delhi, Destination: Chennai, Tickets available:
600]
purchase_tickets(2, 100)
cancel_tickets(2, 50)
LIMITATIONS
1. The code does not handle cases where the train ID is invalid or does not exist. If an
invalid train ID is entered, the system will raise an exception.
2. The code does not handle cases where the number of tickets requested is more than the
maximum number of tickets available per train. This could lead to unexpected behavior
or errors.
3. The code does not handle cases where the number of tickets requested is negative or
zero. This could lead to unexpected behavior or errors.
4. The code does not handle cases where the source and destination stations are invalid or
do not exist. If an invalid station is entered, the system will raise an exception.
5. The code does not provide a way to add new trains or modify existing trains. The list of
trains is fixed and cannot be modified by the user.
CONCLUSION
This system has been made to reduce the manual work when managing train schedules,
availability of the tickets, Number of tickets sold and cancelled and it also allows the
Passengers to book the tickets and cancel them to some degree with some features missing
which are included in the limitations