0% found this document useful (0 votes)
5 views22 pages

Ip Project File - Group 3

The document is a project file for a Railway Management System created by students of Bal Bharati Public School, focusing on organizing train and passenger management using Python, CSV files, and data visualization. It includes objectives, source code, and a menu-driven interface for various functionalities like ticket booking, cancellations, and data visualization. The project aims to simplify railway operations and provide insights into train fares and passenger trends.

Uploaded by

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

Ip Project File - Group 3

The document is a project file for a Railway Management System created by students of Bal Bharati Public School, focusing on organizing train and passenger management using Python, CSV files, and data visualization. It includes objectives, source code, and a menu-driven interface for various functionalities like ticket booking, cancellations, and data visualization. The project aims to simplify railway operations and provide insights into train fares and passenger trends.

Uploaded by

nazz.navya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

------------------------------------------------------------------------------------------------------------------------------

BAL BHARATI PUBLIC SCHOOL


BRIJ VIHAR, GHAZIABAD

(SESSION 2024-25)

INFORMATICS
PRACTICES
PROJECT FILE

TOPIC- RAILWAY MANAGEMENT

-----------------------------SUBMITTED BY GROUP 3------------------------------

Navya Rajvanshi XII-C

Paarth Jain XII-C


Pavni Gupta XII-C

INDEX
S.NO EXPERIMENT SIGN REMARKS
1.
ACKNOWLEDGEMENT
2. CERTIFICATE
3. OBJECTIVES
4. INTRODUCTION
5. CSV TABLES
6. SOURCE CODE
7. OUTPUT
8. BIBLIOGRAPHY
ACKNOWLEDGEMENT
-----------------------------------------------------------------------------

We would like to convey our heartful thanks to Ms.


Preeti Tandon, our Informatics Practices teacher
who always gave us valuable suggestions and
guidelines during the completion of this file. She
has been a source of inspiration during the
completion of our Project. She helped us to
understand and remember the important details of
the project that we would have otherwise lost. Our
Project has been successfully completed only
because of her guidance.
CERTIFICATE
-----------------------------------------------------------------------------

This is to certify that Navya Rajvanshi,


Paarth Jain, Pavni Gupta of class XII-C
have successfully completed their
informatics practices project file under the
guidance of their subject teacher, Ms. Preeti
Tandon.

-----------------------------

PREETI TANDON

(SUBJECT TEACHER)
OBJECTIVES
-----------------------------------------------------------------------------

To organize and manage train details, passenger


records, and schedules systematically using CSV files
and DataFrames.

To simplify tasks like ticket booking, cancellations,


updating train schedules, and passenger details
through a user-friendly interface.

To provide insights into train fares and passenger


trends using bar and line plots for data visualization.

To enable users to access detailed information about


trains, passengers, and schedules conveniently
through a menu-driven system.
-----INTRODUCTION----

The Railway Management System is a Python-based


project designed to streamline train and passenger
management using DataFrames, CSV files, and data
visualization. It handles key operations such as
managing train schedules, passenger records, ticket
bookings, cancellations, and all the details.
The system features a menu-driven interface and
integrates libraries like Pandas for data handling and
Matplotlib for visual insights. Data is organized across
two CSV files: train details, and passenger records,
making the system efficient and user-friendly. This project
offers a practical approach to understanding and
managing railway operations effectively.
----------CSV TABLES----------
train.csv

passenger.csv

SOURCE CODE
-----------------------------------------------------------------------------
import pandas as pd

import matplotlib.pyplot as plt

# Load CSV files into DataFrames

train_df = pd.read_csv('C:/Users/asus/OneDrive/Attachments/train.csv')

passenger_df =
pd.read_csv('C:/Users/asus/OneDrive/Attachments/passenger.csv')

# Function 1: Details About Project

def project_details():
print("\NRailway management system")
print("This project is about managing railways. It allows the user to
modify,delete,add,and display details of trains and passengers.")

#Function 2: Details of all trains


def view_all_trains():
print(“\NTrain details”)
print(train_df)

#Function 3: Details of a Particular Train


def view_particular_train(tnum):
train = train_df[train_df['tnum'] == tnum]
if len(train) == 0:
print("Train not found!")
else:
print(train)

#Function 4: Adding a Train


def add_train(tnum, tname, start, destination, ac_ticket, sleeper_ticket):
new_train = {'tnum': tnum, 'tname': tname, 'start': start, 'destination': destination,
'ac_ticket': ac_ticket, 'sleeper_ticket': sleeper_ticket}
train_df.append(new_train, ignore_index=True)
train_df.to_csv('C:/Users/asus/OneDrive/Attachments/train.csv', index=False)
print(f"Train {tname} added successfully!")

#Function 5: Canceling a Train


def cancel_train(tnum):
updated_train_df = train_df[train_df['tnum'] != tnum]
updated_train_df.to_csv('C:/Users/asus/OneDrive/Attachments/train.csv'
,index=False)
print(f"Train {tnum} canceled successfully!")

#Function 6: Train Fare


def view_train_fare(tnum):
train = train_df[train_df['tnum'] == tnum]
if len(train) == 0:
print("Train not found!")
else:
print(f"AC Fare: {train['ac_ticket'].values[0]},
Sleeper Fare: {train['sleeper_ticket'].values[0]}")

#Function 7: Details of All Passengers


def view_all_passengers():
print("\nPassenger Details")
print(passenger_df)

#Function 8: Details of a Particular Passenger


def view_particular_passenger(pnr_no):
passenger = passenger_df[passenger_df['pnr_no'] == pnr_no]
if len(passenger) == 0:
print("Passenger not found!")
else:
print(passenger)

#Function 9: Ticket Reservation


def reserve_ticket(pname, age, train_no, tclass, destination, amt, status, pnr_no):
new_passenger = {'pname': pname, 'age': age, 'train_no': train_no, 'class': tclass,
'destination': destination, 'amt': amt, 'status': status, 'pnr_no': pnr_no}
passenger_df.append(new_passenger, ignore_index=True)
passenger_df.to_csv('C:/Users/asus/OneDrive/Attachments/passenger.csv',
index=False)
print(f"Ticket reserved successfully for {pname}!")

#Function 10: Status of Ticket


def ticket_status(pnr_no):
passenger = passenger_df[passenger_df['pnr_no'] == pnr_no]
if len(passenger) == 0:
print("Ticket not found!")
else:
print(f"Status: {passenger['status'].values[0]}")

#Function 11: Adding a New Passenger


def add_passenger(pname, age, train_no, tclass, destination, amt, status, pnr_no):
reserve_ticket(pname, age, train_no, tclass, destination, amt, status, pnr_no)

#Function 12: Deleting a Passenger


def delete_passenger(pnr_no):
updated_passenger_df = passenger_df[passenger_df['pnr_no'] != pnr_no]
updated_passenger_df.to_csv('C:/Users/asus/OneDrive/Attachments/passenger.
csv', index=False)
print(f"Passenger with PNR {pnr_no} deleted successfully!")

#Function 13: Updating Passenger Details


def update_passenger_details(pnr_no, new_data):
for key, value in new_data.items():
passenger_df.loc[passenger_df['pnr_no'] == pnr_no, key] = value
passenger_df.to_csv('C:/Users/asus/OneDrive/Attachments/passenger.csv',
index=False)
print("Passenger details updated successfully!")

#Function 14(1): Data Visualization - Train Fare 1


def visualize_fares():
train_df.plot(x='tname', y=['ac_ticket', 'sleeper_ticket'], kind='bar',width=0.4,color=
['purple', 'green'], title='Train Fares')
plt.xlabel('Train Name')
plt.ylabel('Fare Amount')
plt.show()

#Function 14(2): Data Visualization - Train Fare 2


def visualize_fares2():
train_df.plot(x='tname', y=['ac_ticket', 'sleeper_ticket'], kind='barh', width=0.4,
color=['blue', 'red'], title='Train Fares')
plt.xlabel('Fare Amount')
plt.ylabel('Train Name')
plt.show()

#Function 15(1): Data visualization- Passenger count


def visualize_passenger_count():
passenger_counts = passenger_df['train_no'].value_counts()
passenger_counts.plot(kind='line', color='blue', linewidth=2, marker='o',
markersize=8, title='Passenger Count per Train')
plt.xlabel('Train Number')
plt.ylabel('Number of Passengers')
plt.show()

#Function 15(2): Data visualization- Passenger count 2


def visualize_passenger_count2():
passenger_df['amt'].plot(kind='hist', bins=10, color='orange', edgecolor='black',
alpha=0.7, title='Ticket Amount Distribution')
plt.xlabel('Ticket Amount')
plt.ylabel('Frequency')
plt.show()

#Menu to access different functions


def menu():
print("\nRailway Management System Menu")
print("1. Project Details")
print("2. View All Trains")
print("3. View Particular Train")
print("4. Add a Train")
print("5. Cancel a Train")
print("6. View Train Fare")
print("7. View All Passengers")
print("8. View Particular Passenger")
print("9. Reserve Ticket")
print("10. Check Ticket Status")
print("11. Add Passenger")
print("12. Delete Passenger")
print("13. Update Passenger Details")
print("14.1 Visualize Train Fares in bar form")
print("14.2 Visualize train fares in horizontal bars")
print("15.1 Visualize Passenger Count in linechart form")
print("15.2 Visualize Passenger Count in histogram form")
print("16. Exit")

def user_choice():
choice = float(input("Enter your choice: "))
if choice == 1:
project_details()
elif choice == 2:
view_all_trains()
elif choice == 3:
tnum = int(input("Enter Train Number: "))
view_particular_train(tnum)
elif choice == 4:
tnum = int(input("Enter Train Number: "))
tname = input("Enter Train Name: ")
start = input("Enter Start Station: ")
destination = input("Enter Destination Station: ")
ac_ticket = int(input("Enter AC Ticket Price: "))
sleeper_ticket = int(input("Enter Sleeper Ticket Price: "))
add_train(tnum, tname, start, destination, ac_ticket, sleeper_ticket)
elif choice == 5:
tnum = int(input("Enter Train Number to Cancel: "))
cancel_train(tnum)
elif choice == 6:
tnum = int(input("Enter Train Number: "))
view_train_fare(tnum)
elif choice == 7:
view_all_passengers()
elif choice == 8:
pnr_no = int(input("Enter PNR Number: "))
view_particular_passenger(pnr_no)
elif choice == 9:
pname = input("Enter Passenger Name: ")
age = int(input("Enter Passenger Age: "))
train_no = int(input("Enter Train Number: "))
tclass = input("Enter Class (AC/Sleeper): ")
destination = input("Enter Destination: ")
amt = int(input("Enter Amount: "))
status = input("Enter Status (Confirmed/Waiting): ")
pnr_no = int(input("Enter PNR Number: "))
reserve_ticket(pname, age, train_no, tclass, destination, amt, status,
pnr_no)
elif choice == 10:
pnr_no = int(input("Enter PNR Number: "))
ticket_status(pnr_no)
elif choice == 11:
pname = input("Enter Passenger Name: ")
age = int(input("Enter Passenger Age: "))
train_no = int(input("Enter Train Number: "))
tclass = input("Enter Class (AC/Sleeper): ")
destination = input("Enter Destination: ")
amt = int(input("Enter Amount: "))
status = input("Enter Status (Confirmed/Waiting): ")
pnr_no = int(input("Enter PNR Number: "))
add_passenger(pname, age, train_no, tclass, destination, amt, status,
pnr_no)
elif choice == 12:
pnr_no = int(input("Enter PNR Number to Delete: "))
delete_passenger(pnr_no)
elif choice == 13:
pnr_no = int(input("Enter PNR Number to Update: "))
print("Enter new details (leave blank to keep current data):")
pname = input("New Passenger Name: ")
age = input("New Passenger Age: ")
train_no = input("New Train Number: ")
tclass = input("New Class (AC/Sleeper): ")
destination = input("New Destination: ")
amt = input("New Amount: ")
status = input("New Status (Confirmed/Waiting): ")

# Dictionary to hold the updates


updates = {}
if pname:
updates['pname'] = pname
if age:
updates['age'] = int(age)
if train_no:
updates['train_no'] = int(train_no)
if tclass:
updates['class'] = tclass
if destination:
updates['destination'] = destination
if amt:
updates['amt'] = int(amt)
if status:
updates['status'] = status

update_passenger_details(pnr_no, updates)

elif choice == 14.1:


visualize_fares()
elif choice == 14.2:
visualize_fares2()
elif choice == 15.1:
visualize_passenger_count()
elif choice == 15.2:
visualize_passenger_count2()
elif choice == 16:
print("Exiting the system.")
else:
print("Invalid choice, please try again.")

while True:
menu()
user_choice()
ex = int(input("press 0 to exit, or press 1 to continue: "))
if ex == 0:
break
elif ex == 1:
Continue
OUTPUT
----------------------------------------------------------------------------

1.
BIBLIOGRAPHY
-----------------------------------------------------------------------------

NCERT Informatics Practices Class 11th and 12th

Sumita Arora for Class 11th and 12th

Google.com

You might also like