CS Project
CS Project
CS Project
Certificate-----------------------------------3
Acknowledgement------------------------4
Introduction--------------------------------5
Theoretical Background----------------7
Coding ----------------------------------------11
Output-----------------------------------------36
Requirements-------------------------------44
Bibliography---------------------------------45
2
CERTIFICATE
This is to certify that Rishabh Raj of class Twelve,
Date :
Registration No. :
3
ACKNOWLEDGEMENT
I express my sincere thanks to my teacher
Mr. Samir Chattaraj, who guided me to the
successful completion of this project. I take this
opportunity to express my deep sense of gratitude
for their individual guidance, constant
encouragement and immense motivation which
have sustained my efforts at all stages of this
project work.
Rishabh Raj
XII A
4
INTRODUCTION
This project is similar to an Indian
Rail app. It allows the user to
book, cancel, modify or view, their
respective bookings. It allows the
admin to change the train’s
records and their records. There is
also an option for registering the
user in Indian Railways.
5
OBJECTIVE AND SCOPE OF THE PROJECT
6
THEORETICAL BACKGROUND
What is Python?
source or binary form without charge for all major platforms, and
7
Often, programmers fall in love with Python because of the
8
FEATURES OF PYTHON
Python is most preferred language to work on because
of its simplicity, powerful libraries, and readability.
Python provides features listed below :
Simplicity: Think less of the syntax of the language
and more of the code.
9
MySQL Database
MySQL is a fast, easy-to-use RDBMS being used for many
small and big businesses. MySQL is developed, marketed and
supported by MySQL AB, which is a Swedish company.
MySQL is becoming so popular because of many good
reasons −
MySQL is released under an open-source license. So you
have nothing to pay to use it.
MySQL is a very powerful program in its own right. It
handles a large subset of the functionality of the most
expensive and powerful database packages.
MySQL uses a standard form of the well-known SQL data
language.
MySQL works on many operating systems and with
many languages including PHP, PERL, C, C++, JAVA, etc.
MySQL works very quickly and works well even with
large data sets.
MySQL is very friendly to PHP, the most appreciated
language for web development.
MySQL supports large databases, up to 50 million rows
or more in a table. The default file size limit for a table is
4GB, but you can increase this (if your operating system
can handle it) to a theoretical limit of 8 million terabytes
(TB).
MySQL is customizable. The open-source GPL license
allows programmers to modify the MySQL software to
fit their own specific environments.
10
SOURCE CODE
FILE NAME : TABLES
import mysql.connector
mycon=mysql.connector.connect(host='localhost',user='
root',passwd='manager')
cursor=mycon.cursor()
mycon.autocommit=True
s1="create database railway"
cursor.execute(s1)
s1="create table railway(name varchar(100),phno
varchar(15) primary key,age int(4),gender
varchar(50),from_f varchar(100),to_t
varchar(100),date_d varchar(20))"
cursor.execute(s1)
s1="create table user_accounts(fname
varchar(100),lname varchar(100),user_name
varchar(100) ,password varchar(100) primary
key, phno varchar(15),gender
varchar(50),dob varchar(50),age
varchar(4))"
cursor.execute(s1)
11
FILE NAME : MAIN
def menu():
print('1.YES')
print('2.NO')
ch=int(input('DO YOU WANT TO CONTINUE OR NOT:'))
while ch==1:
print('WELECOME TO ONLINE RAILWAY RESERVATION
SYSTEM’)
print('1.SIGN IN')
print('2.SIGN UP')
print('3.DELETE ACCOUNT')
print('4.EXIT')
ch1=int(input('ENTER YOUR CHOICE:'))
if ch1==1:
a=checking()
if a==True:
print('WELCOME')
main()
else:
continue
elif ch1==2:
a=checking_1()
if a==True:
main()
else:
print('PASSWORD ALREADY EXISTS')
continue
elif ch1==3:
12
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:'))
if ch==1:
ticket_booking()
elif ch==2:
ticket_checking()
elif ch==3:
ticket_cancelling()
13
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:')
to=input('enter your destination:')
date1=input('enter date(dd):')
date2=input('enter month(mm):')
date3=input('enter year(yyyy):')
date=date1+"/"+date2+"/"+date3
14
a={'M':'MALE','F':'FEMALE','N':'NOT TO MENTION'}
v=a[Gender]
s1="insert into railway values
('{}',{},{},'{}','{}','{}','{}')".format(nm,phno,age,
v,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 railwaywhere phno=phno"
cursor.execute(s1)
data=cursor.fetchall()[0]
Data=list(data)
15
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:"))
16
if ch==1:
phno=input('enter your phone number:')
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')
17
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])
print(x[5],':::',data[5])
print('
1. yes')
18
print('
2. no')
vi=int(input('enter your choice:'))
if vi==1:
b1="delete from user_accounts
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:")
19
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')
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('{}','{}','{}','{}','{}','{}','{}','{}')".form
at(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')
20
def checking():
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)
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('Hello',data1)
return True
else:
return False
except:
21
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
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:
22
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])
print(x[5],':::',data[5])
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
menu()
23
def menu():
print('1.YES')
print('2.NO')
ch=int(input('DO YOU WANT TO CONTINUE OR NOT:'))
while ch==1:
print('WELECOME TO ONLINE RAILWAY RESERVATION
SYSTEM’)
print('1.SIGN IN')
print('2.SIGN UP')
print('3.DELETE ACCOUNT')
print('4.EXIT')
ch1=int(input('ENTER YOUR CHOICE:'))
if ch1==1:
a=checking()
if a==True:
print('WELCOME')
main()
else:
continue
elif ch1==2:
a=checking_1()
if a==True:
main()
else:
print('PASSWORD ALREADY EXISTS')
continue
elif ch1==3:
c=checking_2()
if c==True:
24
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:'))
if ch==1:
ticket_booking()
elif ch==2:
ticket_checking()
elif ch==3:
ticket_cancelling()
25
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:')
to=input('enter your destination:')
date1=input('enter date(dd):')
date2=input('enter month(mm):')
date3=input('enter year(yyyy):')
date=date1+"/"+date2+"/"+date3
26
a={'M':'MALE','F':'FEMALE','N':'NOT TO MENTION'}
v=a[Gender]
s1="insert into railway values
('{}',{},{},'{}','{}','{}','{}')".format(nm,phno,age,
v,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 railwaywhere phno=phno"
cursor.execute(s1)
data=cursor.fetchall()[0]
Data=list(data)
27
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:"))
28
if ch==1:
phno=input('enter your phone number:')
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')
29
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])
print(x[5],':::',data[5])
print('
3. yes')
30
print('
4. no')
vi=int(input('enter your choice:'))
if vi==1:
b1="delete from user_accounts
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:")
31
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')
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('{}','{}','{}','{}','{}','{}','{}','{}')".form
at(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')
32
def checking():
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)
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('Hello',data1)
return True
else:
return False
except:
33
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
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:
34
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])
print(x[5],':::',data[5])
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
menu()
35
OUTPUT
CHOICE WINDOW
IF CHOICE IS 5 OR MORE
IF CHOICE IS 5 OR MORE
REQUIREMENTS
HARDWARE REQUIRED
Processor : I5
Ram : 4GB
SOFTWARE REQUIRED
44
BIBLIOGRAPHY
• Computer science With Python - Class XII
By : Sumita Arora
• Websites:
https://www.w3resource.com
https://www.tutorialspoint.com/mysql/mys
ql-introduction.htm
https://www.edureka.co/blog/python-
basics/
***
45