Вы находитесь на странице: 1из 22

KENDRIYA VIDYALAYA

MASJID MOTH - 49

A PROJECT FILE ON PYTHON


RAILWAY RESERVATION
A PROJECT IN PYTHON SUBMITTED TO CBSE IN
PARTIAL FULFILLMENT OF THE REQUIREMENT
OF AISSCE – 2020

SUBMITTED BY: GAURAV.


12thA, Roll No. 10.

Under the guidance of: Mr. Jitendra


PGT (C.S)

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.

Mrs. Sushma Chaudhary Mr.Jitendra


(Principal) PGT (C.Sc)

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

This software has been designed for public use


and thus has no Additional requirements. It is
portable and very handy too. Also, no special
training is required to use it. Some of its primary
Requirements are:

 A PC with 512 MB of memory (RAM)


with CD drive.
 Hard Disk with 1 GB space free.
 Mouse and Keyboard.
 Windows XP with SP2
 Software of python

8
Project Coding

RAILWAY RESERVATION:

// coding part paste here


###############################
#create table passengers( pname varchar(100), age
varchar(100), trainno varchar(100), noofpas varchar(100), cls
varchar(100), amt varchar(100), status varchar(100), pnrno
varchar(100) );
#create table traindetail ( tname varchar(100), tnum
varchar(100), ac1 varchar(100), ac2 varchar(100), ac3
varchar(100), slp varchar(100) );
###############################

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()

# GET THE LAST PNR NUMBER


sql="select pnrno from passengers order by pnrno desc limit 1;"
print(sql)
mycursor.execute(sql)
res=mycursor.fetchall()
pnr=1000;
if len(res)>0:
pnr=int(res[0][0])
print(pnr)
print(res)

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")

n=int(input("enter your choice:"))


if(n==1):
10
traindetail()
elif(n==2):
reservation()
elif(n==3):
cancel()
elif(n==4):
displayPNR()
elif(n==5):
exit(0)
else:
print("wrong choice")

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

The project has been liked by everyone and


has been well appreciated. It has made the
whole process of RAILWAY MANAGEMENT
very organized tidy. I had tried my level best
to make successful and good software. Also
the whole experience of working on the
project and then implementing it was very
exciting and knowledgeable. It has given me a
feeling of satisfaction and has given me the
confidence of doing some similar things in
future.

21
BIBLOGRAPHY
In making the project I took the help of
following sources of information:
 Textbook in PYTHON [By Sumita Arora].
 Mr. Jitendra.

22

Вам также может понравиться