0% found this document useful (0 votes)
30 views24 pages

CS Documentation

The document describes a railway management system project in Python. It includes functions to create CSV files for train timings, station codes, and concessions. It also includes functions for ticket booking, PNR status retrieval by number or name, and ticket cancellation using a MySQL database.

Uploaded by

Bharath P Jayan
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)
30 views24 pages

CS Documentation

The document describes a railway management system project in Python. It includes functions to create CSV files for train timings, station codes, and concessions. It also includes functions for ticket booking, PNR status retrieval by number or name, and ticket cancellation using a MySQL database.

Uploaded by

Bharath P Jayan
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/ 24

HOLY TRINITY SCHOOL

(SENIOR SECONDARY) (AFFILIATED TO CBSE, NEW


DELHI AFFILIATION NO-930027 KANJIKODE WEST,
PALAKKAD-678623)

COMPUTER SCIENCE PROJECT

RAILWAY MANAGEMENT SYSTEM

NAME : Bharath P Jayan


CLASS : Xll th
REG.NO :
YEAR: 2022-23
ACKNOWLEDGEMENT
I wish to express my sincere gratitude to my
Principal Mrs.Rekha.T.P and my Computer
Science teacher Ms.Sona Vijayan for all the
help and guidance extended in the completion
of this project on the topic “ Railway
Management System ” .
CONTENTS

i. CERTIFICATE

ii. ACKNOWLEDGMENT

iii. INTRODUCTION TO PYTHON

iv. PROJECT ABSTRACT

v. SOURCE CODE

vi. OUTPUT

vii. BIBLIOGRAPHY
CERTIFICATE

This is to certify that this is the bonafide project work


done by ……………………………….. during the
year 2022-2023.

DATE HEAD OF THE


DEPARTMENT

Submitted for the practical examination held on


……………. at Holy Trinity School, Kanjikode West,
Palakkad, 678623.

PRINCIPAL INTERNAL EXTERNAL


EXAMINER EXAMINER

SCHOOL SEAL
INTRODUCTION TO PYTHON
Programming is important for learning to
innovate and create eco-friendly solutions to
global problems. Programming is also
important in our day-to-day life to enhance the
power of computers and internet.
Python is an interpreted high-level general
purpose programming language. Its design
philosophy emphasizes code readability with its
use of significant indentation. Python is a
popular object-oriented language used both for
stand alone programs and scripting applications
in a variety of domains.
PROJECT ABSTRACT
Railway Ticketing System enables a person to
access the ticketing details and data check
digitally on the web . This eliminates time delay
as the user does not have to visit a ticket
booking centre or stand in long queues . This
facility helps the user to book their tickets and
find out their trip details with a few clicks. It
also makes the process easier and effective.
This project is to help people to easily book
tickets , check the status of their trip bookings .
The objective of this project is to provide the
users easy , effective and time efficient ways to
organize and plan their railway trips . They can
just use their computing devices to book the
tickets and retrieve booking data digitally .
SOURCE CODE
#Introduction To The Program .

print('Hello Ladies And Gentlemen And Welcome To The


Indian Railways\n')

print ('...Loading Your Search Operations...\n')

import csv

#CSV File For Train Timings , Rate And Departure .

def TrainTimings():
f=open('Train Timings.csv','w')
tw=csv.writer(f)

header=['Train Number','Destination','Arrival','Departure
Time','Arrival Time','Rates']
tw.writerow(header)

trains=[[1,'PLKD','TVM','00:25','09:25',800],
[2,'PLKD','TSR','00:25','01:25',400],
[3,'PLKD','EKM','00:25','03:25',650],
[4,'TSR','PLKD','10:25','11:25',450],
[5,'TSR','WYND','10:25','15:25',950],
[6,'TSR','KSRD','10:25','16:25',1100],
[7,'TVM','EKM','05:25','09:25',750],
[8,'TVM','IDK','05:25','11:25',950],
[9,'TVM','KZKD','05:25','10:25',800],
[10,'IDK','PKD','08:25','13:25',950],
[11,'IDK','TVM','08:25','11:25',350],
[12,'IDK','PTM','08:25','10:25',250],
[13,'PTM','PKD','10:25','16:25',900],
[14,'PTM','TVM','10:25','12:25',300],
[15,'PTM','KSRD','10:25','17:25',1000],
[16,'WYND','KSRD','12:25','16:25',500],
[17,'WYND','IDK','12:25','17:25',700],
[18,'WYND','KLLM','12:25','13:25',150],
[19,'KLLM','TSR','07:25','11:25',650],
[20,'KLLM','PLKD','07:25','12:25',800],
[21,'KLLM','TVM','07:25','08:25',150]]
tw.writerows(trains)

f.close()

TrainTimings()

#CSV File For Station Codes .

def stationcodes():
with open('Station Codes.csv','w') as fh:
sw=csv.writer(fh)

header=['Code : Station']
sw.writerow(header)

codes=[['PLKD : Palakkad'],
['TVM : Trivandrum'],
['ALPY : Alapuzha'],
['KLLM : Kollam'],
['IDK : Idukki'],
['KSRD : Kasargod'],
['EKM : Ernakulam'],
['TSR : Thrissur'],
['PTM : Phattanamthitta'],
['KZKD : Kozhikkode'],
['KSRD : Kasargod'],
['IDK : Idukki'],
['MPM : Malappuram'],
['WYND : Wayanad']]

sw.writerows(codes)

stationcodes()

#CSV File For The Concession List .

def concessions():
with open('Concession List.csv','w') as fl:
cw=csv.writer(fl)

header=['Slno.','Designation','Special Concession']
cw.writerow(header)
conc=[[1,'Senior Citizen','30% Rate Reduction'],
[2,'Children Of Upto 6 years','100% rate Reduction'],
[3,'Children Of Ages 7-12','50% Rate Reduction If
Without Berth']]

cw.writerows(conc)

concessions()

#Function For CSV File Displays

def Timings():
print('The Train Timings Are :')
with open('Train Timings.csv','r') as fl:
tr=csv.reader(fl)
for row in tr :
print(row)

def Codes():
print('The Station Codes are :')
with open('Station Codes.csv','r') as fe:
sr=csv.reader(fe)
for row in sr :
print(row)

def Concession():
print('The Concession List For Various Age Demographics:')
with open('Concession List.csv','r') as fa:
cr=csv.reader(fa)
for row in cr :
print(row)

#Function For CSV File Choice

def Operation():
n=int(input('For Operational Details : 1 - Station Codes ; 2 -
Train Timings ; 3 - Concession List ; Station Codes , Train
Timings And Concession List : Press Any Number = '))
if n==1:
Timings()
elif n==2:
Codes()
elif n==3:
Concession()
else :
Timings()
Codes()
Concession()

Operation()

#MySQL Python Connectivity For Main Operations

import mysql.connector

con=mysql.connector.connect(host='localhost',user='root',passw
ord='user',database='passenger')

if con.is_connected():
print('...Loading Your Ticketing Operations...\n')

cursor=con.cursor(buffered=True)
#Exit Message

def fs():
print('Thank You For Visiting Indian Railways . Wish You A
Great Journey')

#Ticket Cancellation

def TD():
pnrdel=input('Enter The Contact Number Of The Ticket To
Delete :')
pnrdel2=pnrdel[:6]
query6="select * from passengerdetails where
PNR='{}'".format(pnrdel2)
cursor.execute(query6)
con.commit()

data=cursor.fetchall()
for i in data:
print(i)
choice=input('Is The Above Tickets The One You Want To
Delete (Y/N) :')

if choice in 'Yy':
query7="delete from passengerdetails where
PNR='{}'".format(pnrdel2)
cursor.execute(query7)
con.commit()
print('The Tickets Have Been Successfully Deleted')
else :
choice=input('You Have Entered The Wrong PNR
Number . Do You Want To Book A New Ticket(B) / Exit(X) /
PNR Status(P) (B/X/P) :')
if choice in 'Bb':
TB()
elif choice in 'Pp':
PR()
else :
fs()

#PNR Status Retrieval


def PR():
contact=input('Enter The Contact Number To Check PNR
Status:')
PNR=contact[:6]

print("('PNR Number','Passenger Name','Age','Date Of


Journey','Departure','Arrival','PNR Status','Preffered
Class','Preffered Berth')")
query2="select * from passengerdetails where
PNR='{}'".format(PNR)
cursor.execute(query2)
con.commit()

data=cursor.fetchall()
for i in data:
print(i)
choice=input('Do You Want To Book A New Ticket(B) /
Exit(X) / Ticket Cancellation(C) (B/X/C) :')
if choice in 'Bb':
TB()
elif choice in 'Cc':
TD()
else :
fs()

#PNR Status Retrieval With Name

def NR():
pasname=input('Enter The Passenger Name Whose PNR
Status You Wnat To Check :')
print("('PNR Number','Passenger Name','Age','Date Of
Journey','Departure','Arrival','PNR Status','Preffered
Class','Preffered Berth')")

query3="select * from passengerdetails where


PasName='{}'".format(pasname)
cursor.execute(query3)
con.commit()

data1=cursor.fetchall()
for i in data1:
print(i)
choice=input('Do You Want To Book A New Ticket(B) /
Exit(X) / PNR Status(P) / Ticket Cancellation(C) (B/X/P/C) :')
if choice in 'Bb':
TB()
elif choice in 'Pp':
PR()
elif choice in 'Cc':
TD()
else :
fs()

#Ticket Booking

def TB():
n=int(input('Enter The Number Of Passengers:'))
for i in range(0,n):
name=input('Enter The Passenger Name (Max 16
Charachters) :')
age=int(input('Enter Passenger Age :'))
doj=input('Date OF Travel In YYYY-MM-DD Format :')
dep=input('Enter The Departure Station Code : ')
arv=input('Enter The Arrival Station Code :')
cont=input('Enter Passenger Conatct Number (Common To
One Ticket) : ')
comp=input("Enter Passenger's Preffered Travelling Class
[Sleeper/3rd AC(Economy/Sleeper/Chair Car)/2nd AC
Sleeper/1st AC Sleeper :")
pref=input("Enter Passenger's Preffered Berth [Side Upper/
Side Lower/Main Middle/Main Upper/Main Lower] :")
pnr=cont[:6]

import random
list=['CNF','WLST','GNWL']
r=random.randrange(3)
status=list[r]
query1="insert into passengerdetails values({},'{}',
{},'{}','{}','{}','{}','{}','{}')".format(pnr,name,age,doj,dep,arv,sta
tus,comp,pref)
cursor.execute(query1)
con.commit()
print('Your Ticket Dteails Have Been Registered . Contact @
[email protected] For Cost And Payement Details \n')
print('Your PNR Number = ',pnr)
choice=input('Do You Want To Check Ticket Status via
PNR(P) / Name(N) / Exit(X) / Ticket Cancellation(C) (P/N/X/C)
:')
if choice in 'Pp':
PR()
elif choice in 'Nn':
NR()
elif choice in 'Cc':
TD()
else :
fs()

#Main Operations Choice

ch=int(input('What Do You Want To Carry Out / 1 - Ticket


Booking / 2 - PNR Status / 3 - Ticket Retrieval With Passenger
Name / 4 - Ticket Cancellation :'))
if ch==1 :
TB()
elif ch==2 :
PR()
elif ch==3:
NR()
else :
TD()

con.close()

#End Of Program
OUTPUT
BIBLIOGRAPHY
 Computer Science NCERT text book

 Computer Science with Python- Sumita Arora

 www.google.com

You might also like