0% found this document useful (0 votes)
25 views27 pages

RMS CS PRJ

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)
25 views27 pages

RMS CS PRJ

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
You are on page 1/ 27

BRIDGEWELL GLOBAL SCHOOL, SARAKANA

SESSION: 2024-25

COMPUTER SCIENCE PROJECT

TOPIC: Railway Management

Name: RUDRA MADHAB SAHOO

Class: XII

Roll no:

Guided by: Mrs. Madhusmita Sahu


BIO DATA

STUDENT’S NAME: RUDRA MADHAB SAHOO

CLASS: XII

ROLL NO:

PROJET: Computer Science Project

PROJECT TITLE: RAILWAY MANAGEMENT

EXAMINATION: AISSCE-2024-25
CERTIFICATE

This is to certify that RUDRA MADHAB SAHOO of class – XII


bearing C.B.S.E. Roll No: _____________ has successfully
completed and submitted the project entitled “RAILWAY
MANAGEMENT” for the partial fulfillment of computer
science project for ALL INDIA SENIOR SCHOOL CERTIFICATE
EXAMINATION [A.I.S.S.C.E] for the session 2024-25.

It embodies the work by him under my supervision.

Mrs. Madhusmita Sahu


COMPUTER TEACHER

Signature of internal guide Signature of external guide

A.I.S.S.C.E
ACKNOWLEDGEMENT

I express my heartfelt of gratitude and indebtedness to


my teacher Mrs. Madhusmita Sahu for her encouragement,
valuable suggestions & able guidance in the execution of
computer project.

I am also thankful to our respected principal Mr.


Abhaya Kumar Jena for providing us various facilities to
complete this project.

Lastly, I would like to convey my special thanks to


my parents and friends in giving me all encouragement to
carry out my field work & complete this project.

RUDRA MADHAB SAHOO


CONTENTS

 Introduction
 About Python
 About Binary File
 Description of variables used
 Description of the user defined Functions
 Description of python module in the code
 Software Requirement
 Hardware Requirement
 Conclusion
INTRODUCTION
Features:

1. Add Train:
o Allows the user to add a new train with details like

train number, name, source, destination, and


available seats.

2. Display All Trains:


o Displays all the trains stored in the binary file in a

well-formatted manner.

3. Search Train:
o Searches for a train by its train number and displays

the details if found.

4. Update Train:
o Updates the details of an existing train.

5. Delete Train:
o Deletes a train record by its train number.

6. Exit:
o Exits the program.
Steps to Run:
1. Save the code in a file named
railway_management.py

2. Run the script in a Python environment.

3. The program will create a binary file


trains.dat to store train details.

4. Use the menu-driven interface to manage train


records.

Notes:
 This project uses pickle for binary file
operations.

 Handle the trains.dat file carefully to avoid


accidental deletion.

 The program includes basic error handling for


robustness.
What is python?
Python is a popular programming language.it was
created by Guido van Rossum, and released in
1991.
It is used for:
 Web development
 Software development
 Data analysis
 System scripting

What python can do?


 Python can be used on a server to create
web applications.
 Python can be used alongside software to
create workflows.
 Python can connect to database systems.it
can also read and modify files.
 Python can be used for rapid prototyping or
for production-ready software
development.
What is Binary File?
 Binary files used to read and write text, images or audio and video file
formats. Binary files read and write the data in the form of bytes.
 Binary files are not in human readable format as information in binary
code. And many operations like search, update, insertion and deletion of
record can be done in binary file.
 Binary files can be open using open () and with statement. Various
modes of binary files we have discussed in starting of this chapter like
‘rb’, ‘wb’, ’ab’, ‘rb+’, ’wb+’ and ‘ab+’
 The binary file can be opened using open () function followed by the file
name and mode of opening.
File object= open (“file name”, “mode”)
 It can also be opened using with keyword where the user no need to
close the fie.
with open (“file name”, “mode”) as file object
 The Close () function is used to close the currently opened binary file.
File object.close ()

What is pickle Module?


 pickle module is use to convert the python objects like class, list, tuple,
dictionary into binary data in the forms of bytes. This process is called
pickling or serialization. So, data associated to these objects write into
binary file using the pickling.
 pickling is done using dump () method of pickle module:
pickle.dump(object, file-object)

 When the objects are stored into binary file, we can read it by converting
byte stream back into python objects this process is known as unpickle.
Unpickling is done by using the load () functions of pickle module.
object=pickle.load(file-object)

 The load () function reads byte streams from binary file convert and
returns the Object.
MINIMUM SOFTWARE REQUIREMENT

 Python 3.x onwards

 Microsoft Windows Operating system (Version 11)

 Microsoft office word 2021


import pickle
import os

# File to store railway data


FILE_NAME = "railway_data.dat"

# Function to initialize the binary file


def initialize_file():
if not os.path.exists(FILE_NAME):
with open(FILE_NAME, 'wb') as f:
pickle.dump([], f)

# Function to add a train record


def add_train():
train_no = input("Enter Train Number: ")
name = input("Enter Train Name: ")
source = input("Enter Source Station: ")
destination = input("Enter Destination Station: ")
departure = input("Enter Departure Time (HH:MM): ")
arrival = input("Enter Arrival Time (HH:MM): ")
train = {
"train_no": train_no,
"name": name,
"source": source,
"destination": destination,
"departure": departure,
"arrival": arrival
}

with open(FILE_NAME, 'rb') as f:


data = pickle.load(f)
data.append(train)

with open(FILE_NAME, 'wb') as f:


pickle.dump(data, f)
print("Train added successfully!")

# Function to view all train records


def view_trains():
with open(FILE_NAME, 'rb') as f:
data = pickle.load(f)
if not data:
print("No train records found!")
return

print("\nTrain Records:")
print("-" * 60)
for train in data:
print(f"Train No: {train['train_no']}, Name:
{train['name']}, "
f"Source: {train['source']}, Destination:
{train['destination']}, "
f"Departure: {train['departure']}, Arrival:
{train['arrival']}")
print("-" * 60)

# Function to search for a train by number


def search_train():
train_no = input("Enter Train Number to Search: ")
with open(FILE_NAME, 'rb') as f:
data = pickle.load(f)

for train in data:


if train["train_no"] == train_no:
print("Train Found:")
print(f"Train No: {train['train_no']}, Name:
{train['name']}, "
f"Source: {train['source']}, Destination:
{train['destination']}, "
f"Departure: {train['departure']}, Arrival:
{train['arrival']}")
return

print("Train not found!")

# Function to update train details


def update_train():
train_no = input("Enter Train Number to Update: ")
with open(FILE_NAME, 'rb') as f:
data = pickle.load(f)

for train in data:


if train["train_no"] == train_no:
print("Train Found! Enter new details (leave
blank to keep unchanged):")
name = input(f"Enter Train Name
[{train['name']}]: ") or train["name"]
source = input(f"Enter Source Station
[{train['source']}]: ") or train["source"]
destination = input(f"Enter Destination Station
[{train['destination']}]: ") or train["destination"]
departure = input(f"Enter Departure Time
[{train['departure']}]: ") or train["departure"]
arrival = input(f"Enter Arrival Time
[{train['arrival']}]: ") or train["arrival"]

train.update({
"name": name,
"source": source,
"destination": destination,
"departure": departure,
"arrival": arrival
})

with open(FILE_NAME, 'wb') as f:


pickle.dump(data, f)
print("Train details updated successfully!")
return

print("Train not found!")

# Function to delete a train record


def delete_train():
train_no = input("Enter Train Number to Delete: ")
with open(FILE_NAME, 'rb') as f:
data = pickle.load(f)

for train in data:


if train["train_no"] == train_no:
data.remove(train)
with open(FILE_NAME, 'wb') as f:
pickle.dump(data, f)
print("Train record deleted successfully!")
return

print("Train not found!")

# Main menu
def menu():
initialize_file()
while True:
print("\n=== Railway Management System ===")
print("1. Add Train")
print("2. View Trains")
print("3. Search Train")
print("4. Update Train")
print("5. Delete Train")
print("6. Exit")
choice = input("Enter your choice: ")

if choice == "1":
add_train()
elif choice == "2":
view_trains()
elif choice == "3":
search_train()
elif choice == "4":
update_train()
elif choice == "5":
delete_train()
elif choice == "6":
print("Exiting... Thank you!")
break
else:
print("Invalid choice! Please try again.")

# Run the program


menu()
=== Railway Management System ===
1. Add Train
2. View Trains
3. Search Train
4. Update Train
5. Delete Train
6. Exit
Enter your choice: 1
Enter Train Number: 100
Enter Train Name: INDIAN
Enter Source Station: odisha
Enter Destination Station: delhi
Enter Departure Time (HH:MM): 2:00
Enter Arrival Time (HH:MM): 9:00
Train added successfully!

=== Railway Management System ===


1. Add Train
2. View Trains
3. Search Train
4. Update Train
5. Delete Train
6. Exit
Enter your choice: 1
Enter Train Number: 108
Enter Train Name: bullet train
Enter Source Station: chicago
Enter Destination Station: sydney
Enter Departure Time (HH:MM): 11:00
Enter Arrival Time (HH:MM): 12:00
Train added successfully!

=== Railway Management System ===


1. Add Train
2. View Trains
3. Search Train
4. Update Train
5. Delete Train
6. Exit
Enter your choice: 2
Train Records:
------------------------------------------------------------
Train No: 101, Name: sambalpuri express, Source:
bhubaneswar, Destination: sambalpur, Departure: 12:00,
Arrival: 4:30:
Train No: 102, Name: bombay express, Source: nayagarj,
Destination: h, Departure: , Arrival: Enter Destination
Station: h
Train No: 101, Name: konark express, Source: bhubaneswar,
Destination: mumbai, Departure: 1:00, Arrival: 12:00
Train No: 101, Name: konark express, Source: bhubaneswar,
Destination: sambalpur, Departure: 12:00, Arrival: 7:00
Train No: 102, Name: vande bharat express, Source:
bombay, Destination: goa, Departure: 2:00, Arrival: 5:00
Train No: 108, Name: cn, Source: uganda, Destination:
japan, Departure: 8:00, Arrival: 4:00
Train No: 101, Name: konark express, Source: bhubaneswar,
Destination: sambalpur, Departure: 12:00, Arrival: 7:00
Train No: 105, Name: vande bharat express, Source:
bhubaneswar, Destination: mumbai, Departure: 2:00,
Arrival: 9:00
Train No: 108, Name: chennai express, Source: pune,
Destination: chennai, Departure: 8, Arrival: 5:00
Train No: 101, Name: bullet train, Source: tokyo,
Destination: kasukabe, Departure: 2:00, Arrival: 3:00
Train No: 202, Name: jammu express, Source: , Destination:
, Departure: Enter Train Name: bullet train, Arrival:
Train No: 111, Name: jammu express, Source: jammu,
Destination: punjab, Departure: 12:00, Arrival: 2:00
Train No: chennai express, Name: 11, Source: ab,
Destination: h, Departure: 00, Arrival: 00
Train No: 100, Name: bullet train, Source: tokyo,
Destination: kasukabe, Departure: 7:00, Arrival: 8:00
Train No: 100, Name: INDIAN, Source: odisha, Destination:
delhi, Departure: 2:00, Arrival: 9:00
Train No: 108, Name: bullet train, Source: chicago,
Destination: sydney, Departure: 11:00, Arrival: 12:00
------------------------------------------------------------

=== Railway Management System ===


1. Add Train
2. View Trains
3. Search Train
4. Update Train
5. Delete Train
6. Exit
Enter your choice: 3
Enter Train Number to Search: 108
Train Found:
Train No: 108, Name: cn, Source: uganda, Destination:
japan, Departure: 8:00, Arrival: 4:00

=== Railway Management System ===


1. Add Train
2. View Trains
3. Search Train
4. Update Train
5. Delete Train
6. Exit
Enter your choice: 4
Enter Train Number to Update: 100
Train Found! Enter new details (leave blank to keep
unchanged):
Enter Train Name [bullet train]:
Enter Source Station [tokyo]:
Enter Destination Station [kasukabe]: osaka
Enter Departure Time [7:00]:
Enter Arrival Time [8:00]:
Train details updated successfully!
=== Railway Management System ===
1. Add Train
2. View Trains
3. Search Train
4. Update Train
5. Delete Train
6. Exit
Enter your choice: 5
Enter Train Number to Delete: 100
Train record deleted successfully!

=== Railway Management System ===


1. Add Train
2. View Trains
3. Search Train
4. Update Train
5. Delete Train
6. Exit
Enter your choice: 6
Exiting... Thank you!
In conclusion, the Railway Management System
project highlights the importance of technology
in streamlining operations within the railway
sector. It demonstrates how efficient data
management can enhance ticket booking,
scheduling, and resource allocation. The system
ensures accuracy, saves time, and improves
passenger satisfaction. By integrating
automation and user-friendly interfaces, it also
emphasizes the role of innovation in modern
transportation. This project serves as a stepping
stone for further advancements in railway
management systems.
BIBLIOGRAPHY

1)Books

2)Online Resources

3)Tutorials & Articles

4)Research papers

You might also like