CS Documentation
CS Documentation
i. CERTIFICATE
ii. ACKNOWLEDGMENT
v. SOURCE CODE
vi. OUTPUT
vii. BIBLIOGRAPHY
CERTIFICATE
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 .
import csv
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()
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()
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()
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)
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()
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()
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()
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')")
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()
con.close()
#End Of Program
OUTPUT
BIBLIOGRAPHY
Computer Science NCERT text book
www.google.com