Python Railway File
Python Railway File
Python Railway File
MASJID MOTH - 49
1
INDEX
S.No TOPIC Pg No.
1 Name of Project 1
2. Acknowledgement 4
3. Certificate 5
4. Background 6
5. Preface 7
6. System requirements 8
7. Program coding with 9-20
outputs
8. Conclusion & summary 21
9. Bibliography 22
10. End of project 22 - END
2
RAILWAY
RESERVATION
3
ACKNOWLEDGEMENT
We deem it our proud privilege for this opportunity.
To express my deep and sincere gratitude and
acknowledge the guidance of our respected Teacher
Mr. Jitendra, PGT PYTHON who helped me a lot by
giving valuable suggestions & facts regarding the
project. We would like to thank our Teacher whose
suggestions helped me in successful completion of
this project. He provided us various reference books
which were extremely useful for me. Lastly express
our sincere thanks to each other in completing this
project.
4
KENDRIYA VIDYALAYA
MASJID MOTH -49
CERTIFICATE
This is to certify that GAURAV of class 12th ‘A’ have
developed a project file under my supervision and
guidance. The works done by him is up to the
satisfactory level and have developed this project
with great efforts and sincerity.
5
BACKGROUND
It so happened that one day I went to RAILWAY
STATION. I noticed that the manager was much
tensed. On being enquired by me, he told me that
everything in the RAILWAY STATION was messed up.
He told me that keeping records of the passenger
manually was extremely difficult.
At that time I got the idea of designing handy and
easy to use software so that I could help the
manager. This program provides all required
facilities. It provides the facility to keep the records
of passenger in a much easier and efficient way. With
the help of large database. So I developed “RAILWAY
RESERVATION”
And it has made the whole work more systematic and
organized
6
PREFACE
As soon as I felt the need of our project, I started
investing the existing manual file management
system so that I could look out for possible
modification. Then I conducted a small interview with
railway manager so that I could get some possible
suggestions. He told us about the requirement. After
that I did on-site observation to analyse the system in
a much better way. Then I designed the projects per
the needs. Then I did the coding of the software and
test it to evaluate the system’s compliance with its
specified requirements. Lastly I gave him a copy of my
software. The result was satisfactory.
So I replaced the old manual system by this new
computerized system. Now everything is very well !
7
System Requirement
8
Project Coding
RAILWAY RESERVATION:
import mysql.connector
#import MySQLdb
#import os
#import platform
#import pandas as pd
#pnr=1010
mydb=mysql.connector.connect(host="localhost",user="root",pa
sswd="123456",database="rail");
9
#mydb = MySQLdb.connect(host="localhost", user="root",
db="rail")
mycursor=mydb.cursor()
def railresmenu():
print("Railway Reservation ")
print("1.Train Detail")
print("2.Reservation of Ticket")
print("3.Cancellation of Ticket")
print("4.Display PNR status")
print("5.Quit")
def traindetail():
print("Train Details")
ch='y'
while (ch=='y'):
l=[]
name=input("enter train name :")
l.append(name)
tnum=int(input("enter train number :"))
l.append(tnum)
ac1=int(input("enter number of AC 1 class
seats"))
l.append(ac1)
ac2=int(input("enter number of AC 2 class
seats"))
l.append(ac2)
ac3=int(input("enter number of AC 3 class
seats"))
11
l.append(ac3)
slp=int(input("enter number of sleeper class
seats"))
l.append(slp)
train=(l)
sql="insert into
traindetail(tname,tnum,ac1,ac2,ac3,slp)
values(%s,%s,%s,%s,%s,%s)"
mycursor.execute(sql,train)
mydb.commit()
print("insertion completed")
print("Do you want to insert more train
Detail")
ch=input("enter yes/no")
print('\n' *10)
print("===============================================
====================")
railresmenu()
def reservation():
global pnr
l1=[]
pname=input("enter passenger name=")
l1.append(pname)
age=input("enter age of passenger =")
l1.append(age)
trainno=input("enter train number")
l1.append(trainno)
np=int(input("Enter number of passanger:"))
12
l1.append(np)
print("select a class you would like to travel in")
print("1.AC FIRST CLASS")
print("2.AC SECOND CLASS")
print("3.AC THIRD CLASS")
print("4.SLEEPER CLASS")
cp=int(input("Enter your choice:"))
if(cp==1):
amount=np*1000
cls='ac1'
elif(cp==2):
amount=np*800
cls='ac2'
elif(cp==3):
amount=np*500
cls='ac3'
else:
amount=np*350
cls='slp'
l1.append(cls)
print("Total amount to be paid:",amount)
l1.append(amount)
pnr=pnr+1
print("PNR Number:",pnr)
print("status: confirmed")
sts='conf'
l1.append(sts)
l1.append(pnr)
train1=(l1)
sql="insert into
13
passengers(pname,age,trainno,noofpas,cls,amt,status,pnrno)
values(%s,%s,%s,%s,%s,%s,%s,%s)"
mycursor.execute(sql,train1)
mydb.commit()
print("insertion completed")
print("Go back to menu")
print('\n' *10)
print("===============================================
====================")
railresmenu()
railresmenu()
def cancel():
print("Ticket cancel window")
pnr=input("enter PNR for cancellation of Ticket")
pn=(pnr,)
sql="update passengers set status='deleted' where
pnrno=%s"
mycursor.execute(sql,pn)
mydb.commit()
print("Deletion completed")
print("Go back to menu")
print('\n' *10)
print("===============================================
====================")
railresmenu()
railresmenu()
14
def displayPNR():
print("PNR STATUS window")
pnr=input("enter PNR NUMBER")
pn=(pnr,)
sql="select * from passengers where pnrno=%s"
mycursor.execute(sql,pn)
res=mycursor.fetchall()
#mydb.commit()
print("PNR STATUS are as follows : ")
print("(pname,age,trainno, noofpas,cls,amt,status,
pnrno)")
for x in res:
print(x)
#print("Deletion completed")
print("Go back to menu")
print('\n' *10)
print("===============================================
====================")
railresmenu()
railresmenu()
railresmenu()
15
OUTPUTS:-
16
17
18
19
20
CONCLUSION AND SUMMARY
21
BIBLOGRAPHY
In making the project I took the help of
following sources of information:
Textbook in PYTHON [By Sumita Arora].
Mr. Jitendra.
22