Cs 12
Cs 12
RAILWAY RESERVATION
SYSTEM
“The train is a small world moving through a larger world.”
Done by:
POUNAMI ROY
1
(Panisagar, North Tripura - 799260)
COMPUTER SCIENCE
Certified to be the Bonafide Record of work done by POUNAMI ROY
of Std XII in the Computer Science Lab of PM SHRI KENDRIYA
VIDYALAYA PANISAGAR, NORTH TRIPURA, during the year 2024 –
20225
Date: Teacher-in-charge
2
ACKNOWLEDGEMENT
3
TABLE OF CONTENT
4
1.OVERVIEW OF PYTHON AND ITS
VARIOUS OBJECTS
5
6. Built-in objects are components of extensions. For more complex tasks,
you still may need to provide your own objects, using Python classes or C
language interfaces. But as you’ll see in later parts of this book, objects
implemented manually are often built on top of built-in types such as lists
and dictionaries. For instance, a stack data structure may be implemented as
a class that manages or customizes a built-in list.
7. Built-in objects are often more efficient than custom data structures.
Python’s built-in types employ already optimized data structure algorithms
that are implemented in C for speed. Although you can write similar object
types on your own, you’ll usually be hard-pressed to get the level of
performance built-in object types provide.
8. Built-in objects are a standard part of the language. In some ways,
Python borrows both from languages that rely on built-in tools (e.g., LISP)
and languages that rely on the programmer to provide tool implementations
or frameworks of their own (e.g., C++). Although you can implement unique
object types in Python, you don’t need to do so just to get started. Moreover,
because Python’s built-ins are standard, they’re always the same; proprietary
frameworks, on the other hand, tend to differ from site to site.
9. Easy-to-learn − Python has few keywords, simple structure, and a clearly
defined syntax. This allows the student to pick up the language quickly.
10.Easy-to-read − Python code is more clearly defined and visible to the eyes.
11.Easy-to-maintain − Python's source code is fairly easy-to-maintain.
12.A broad standard library − Python's bulk of the library is very portable
and cross-platform compatible on UNIX, Windows, and Macintosh.
13.Interactive Mode − Python has support for an interactive mode which
allows interactive testing and debugging of snippets of code.
14.Portable − Python can run on a wide variety of hardware platforms and has
the same interface on all platforms.
6
15.Extendable − You can add low-level modules to the Python interpreter.
These modules enable programmers to add to or customize their tools to be
more efficient.
16.Databases − Python provides interfaces to all major commercial databases.
17.GUI Programming − Python supports GUI applications that can be created
and ported to many system calls, libraries and windows systems, such as
Windows MFC, Macintosh, and the X Window system of Unix.
18.Scalable − Python provides a better structure and support for large programs
than shell scripting.
Python too supports file handling and allows users to handle files
i.e., to read and write files, along with many other file handling options, to
operate on files. The concept of file handling has stretched over various other
languages, but the implementation is either complicated or lengthy, but alike
other concepts of Python, this concept here is also easy and short. Python treats
file differently as text or binary and this is important. Each line of code includes
a sequence of characters and they form text file. Each line of a file is terminated
with a special character, called the EOL or End of Line characters like comma
{,} or newline character. It ends the current line and tells the interpreter a new
one has begun. Let’s start with Reading and Writing files. There are also
various other functions that help to manipulate the files and its contents. One
can explore various other functions in Python Docs.
7
2.PROJECT DESCRIPTION
done with help of python language. This project is very use full for the people to book or
cancel train tickets by sitting at home with one cell phone in their hand. This project can be
Functional Features
1. The objective of this project is to let the students apply the programming
knowledge into a real- world situation/problem and exposed the students
how programming skills helps in developing a good software.
2. Write programs utilizing modern software tools.
3. Apply object oriented programming principles effectively when
developing small to medium sized projects.
4. Write effective procedural code to solve small to medium sized
problems.
5. Students will demonstrate a breadth of knowledge in computer science,
as exemplified in the areas of systems, theory and software development.
6. Students will demonstrate ability to conduct a research or applied
Computer Science project, requiring writing and presentation skills
which exemplify scholarly style in computer science.
Technology Used:
• Windows OS
• Python
• mysql connector modulle
• CSV file for storing data
8
3.FUCNTIONS USED
9
defchecking_2(): This function takes the user to delete
account page
3.SOURCE CODE
FILE NAME : TABLES
import mysql.connector
mycon=mysql.connector.connect(host='localhost',
user='root',passwd='manager')
cursor=mycon.cursor()
mycon.autocommit=True
cursor.execute(s1)
cursor.execute(s1)
10
cursor.execute(s1)
11
if a==True:
main()
else:
print('PASSWORD ALREADY EXISTS')
continue
elif ch1==3:
c=checking_2()
if c==True:
print('ACCOUNT DELETED’)
continue
else:
print('YOUR PASSWAORD OR USER_NAME IS INCORRECT')
continue
elif ch1==4:
print('THANK YOU')
break
else:
print('ERROR 404:PAGE NOT FOUND')
break
def main():
print('1.yes')
print('2.no')
c=int(input("do you want to continue or not:")
while (c==1):
print(' 1.TICKET BOOKING',"\n", '2.TICKET
CHECKING',"\n",'3.TICKET,
CANCELLING'"\n",'4.ACCOUNT
DETAILS',"\n",'5.LOG OUT')
ch=int(input('enter ur choice:'))
12
if ch==1:
ticket_booking()
elif ch==2:
ticket_checking()
elif ch==3:
ticket_cancelling()
elif ch==4:
checking_3()
elif ch==5:
print('THANK YOU')
break
else:
print('ERROR 404: ERROR PAGE NOT FOUND')
def ticket_booking():
import mysql.connector
Mycon=mysql.connector.connect (host='localhost',
User='root', passwd='manager',
database='railway')
Cursor=mycon.cursor ()
mycon.autocommit=True
nm=input('enter your name:')
phno=input('enter your phone number:')
age=int(input('enter your age:'))
print(' M=MALE','\n','F=FEMALE','\n','N=NOT TO
MENTION')
gender=input('enter your gender:')
Gender=gender.upper()
fr=input('enter ur starting point:')
13
to=input('enter your destination:')
date1=input('enter date(dd):')
date2=input('enter month(mm):')
date3=input('enter year(yyyy):')
date=date1+"/"+date2+"/"+date3
a={'M':'MALE','F':'FEMALE','N':'NOT TO MENTION'}
v=a[Gender]
s1="insert into railway values ('{}',{},{},'{}',
'{}','{}','{}')".format(nm,phno,agev,
fr,to,date)
cursor.execute(s1)
print('BOOKED SUCCESSFULLY')
def ticket_checking():
import mysql.connector
mycon=mysql.connector.connect(host='localhost',
user='root',passwd='manager',
database='railway')
cursor=mycon.cursor()
mycon.autocommit=True
print('1.yes')
print('2.no')
ch=int(input("do you want to continue or not:"))
if ch==1:
phno=int(input('enter your phnone number:'))
try:
s1="select * from railwaywherephno=phno"
cursor.execute(s1)
data=cursor.fetchall()[0]
14
Data=list(data)
a=['NAME','PHONE,NUMBER','AGE','GENDER',
'STARTING POINT','DESTINATION','DATE',]
print(a[0],'::::',Data[0].upper())
print(a[1],'::::',Data[1])
print(a[2],'::::',Data[2])
print(a[3],'::::',Data[3].upper())
print(a[4],'::::',Data[4].upper()
print(a[5],'::::',Data[5].upper())
print(a[6],'::::',Data[6])
except:
print('TICKET DOES NOT EXISTS')
elif ch==2:
print('THANK YOU')
else:
print('ERROR 404:PAGE NOT FOUND')
def ticket_cancelling():
import mysql.connector
mycon=mysql.connector.connect(host='localhost',
user='root',passwd='manager',
database='railway')
cursor=mycon.cursor()
mycon.autocommit=True
print('1.yes')
print('2.no')
ch=int(input("do you want to continue or not:"))
if ch==1:
phno=input('enter your phone number:')
15
s1="delete from railway where phno=phno"
cursor.execute(s1)
print('TICKET CANCELLED')
elif ch==2:
print('THANK YOU')
else:
print('ERROR 404:PAGE NOT FOUND')
def checking_2():
import mysql.connector
mycon=mysql.connector.connect(host='localhost',
user='root',passwd='manager',
database='railway')
cursor=mycon.cursor()
mycon.autocommit=True
a=input('USER NAME:')
b=input('PASS WORD:')
try:
s1="select user_name from user_accounts
where password='{}'".format(b)
cursor.execute(s1)
data=cursor.fetchall()[0]
data=list(data)
if data[0]==a:
print('IS THIS YOUR ACCOUNT')
s1="select user_name from
user_accounts where
password='{}'".format(b)
c1="select fname,lname from
user_accounts where
16
password='{}'".format(b)
cursor.execute(c1)
data1=cursor.fetchall()[0]
data1=list(data1)
data1=data1[0]+' '+data1[1]
cursor.execute(s1)
data=cursor.fetchall()[0]
data=list(data)
if data[0]==a:
x=['FIRST NAME','LAST NAME','PHONE
NUMBER','GENDER','DATE OF
BIRTH','AGE']
s1="select fname,lname,phno,gender,
dob,age from user_accountswhere
password='{}'".format(b)
cursor.execute(s1)
data=cursor.fetchall()[0]
data=list(data)
print(x[0],':::',data[0])
print(x[1],':::',data[1])
print(x[2],':::',data[2])
print(x[3],':::',data[3])
print(x[4],':::',data[4])
print(x[5],':::',data[5])
print('1.yes')
print('2.no')
vi=int(input('enter your choice:'))
if vi==1:
b1="delete from user_accounts
17
where password = '{}'"
.format(b)
cursor.execute(b1)
return True
elif vi==2:
print('SORRY,RETRY')
else:
print('ERROR 404:PAGE NOT FOUND')
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
def checking_1():
import mysql.connector
mycon=mysql.connector.connect(host='localhost',
user='root',passwd='manager',
database='railway')
cursor=mycon.cursor()
mycon.autocommit=True
f=input("FIRST NAME:")
l=input("LAST NAME:")
a=input('USER NAME:')
b=input('PASS WORD:')
c=input('RE-ENTER YOUR PASS WORD:')
ph=input("PHONE NUMBER:")
print('M=MALE','\n','F=FEMALE','\n',
'N=NOT TO MENTION')
18
gen=input('ENTER YOUR GENDER:')
print("ENTER YOR DATE OF BIRTH")
d=input("DD:")
o=input("MM:")
p=input("YYYY:")
dob=d+'/'+o+'/'+p
age=input('YOUR AGE:')
v={'m':'MALE','f':'FEMALE','n':'NOT TO MENTION'}
if b==c:
try:
c1="insert into user_accounts
values('{}','{}','{}','{}','{}',
'{}','{}','{}')".format
(f,l,a,b,ph,v[gen],dob,age)
cursor.execute(c1)
print('WELCOME',f,l)
return True
except:
print('PASSWORD ALREADY EXISTS')
return False
else:
print('BOTH PASSWORDS ARE NOT MATCHING')
def checking():
import mysql.connector
mycon=mysql.connector.connect(host='localhost',
user='root',passwd='manager',
database='railway')
cursor=mycon.cursor()
19
mycon.autocommit=True
a=input('USER NAME:')
b=input('PASS WORD:')
try:
s1="select user_name from user_accounts where
password='{}'".format(b)
c1="select fname,lname from user_accounts
where password='{}'".format(b)
cursor.execute(c1)
data1=cursor.fetchall()[0]
data1=list(data1)
data1=data1[0]+' '+data1[1]
cursor.execute(s1)
data=cursor.fetchall()[0]
data=list(data)[0]
if data==a:
print(' HII ',data1)
return True
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
def checking_3():
import mysql.connector
mycon=mysql.connector.connect(host='localhost',
user='root',passwd='manager',
database='railway')
cursor=mycon.cursor()
mycon.autocommit=True
20
a=input('USER NAME:')
b=input('PASS WORD:')
try:
s1="select user_name from user_accounts where
password='{}'".format(b)
c1="select fname,lname from user_accounts
where password='{}'".format(b)
cursor.execute(c1)
data1=cursor.fetchall()[0]
data1=list(data1)
data1=data1[0]+' '+data1[1]
cursor.execute(s1)
data=cursor.fetchall()[0]
data=list(data)
if data[0]==a:
x=['FIRST NAME','LAST NAME','PHONE
NUMBER','GENDER','DATE OF
BIRTH','AGE']
s1="select fname,lname,phno,gender,
dob,age from user_accounts where
password='{}'".format(b)
cursor.execute(s1)
data=cursor.fetchall()[0]
data=list(data)
print(x[0],':::',data[0])
print(x[1],':::',data[1])
print(x[2],':::',data[2])
print(x[3],':::',data[3])
print(x[4],':::',data[4])
21
print(x[5],':::',data[5])
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
menu()
5.SAMPLE OUTPUT
CHOICE WINDOW
22
IF CHOICE IS2(SIGN UP WINDOW)
23
IF CHOICE IS3(DELETE ACCOUNT)
24
IF CHOICE IS4(EXIT)
25
SECOND CHOICE LIST AFTER LOGIN
26
IF CHOICE IS2(TICKET CHECKING)
27
IF CHOICE IS3(TICKET CANCELLING)
28
IF CHOICE IS4(ACCOUNT DETAILS)
29
IF CHOICE IS5 OR MORE
6. CONCLUSION
30
The main of developing reservation system is to provide all information
that is required by the users.
User friendliness is a must that is the user must get the details without
complicated searching procedures .
31
7.BIBLIOGRAPHY
32