0% found this document useful (0 votes)
60 views38 pages

Cs Report

This document contains a certificate certifying that a student named Poojita Amanaganti successfully completed a computer science project on developing a website similar to MakeMyTrip for flights booking using Python and MySQL. It includes an index listing the various sections of the project report such as acknowledgements, aim and introduction, software and hardware used, code, output, and bibliography. The project aims to create a user-friendly application for viewing flight details and booking tickets between different cities in India by connecting to a database of flight information stored in MySQL tables.

Uploaded by

अनंत
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views38 pages

Cs Report

This document contains a certificate certifying that a student named Poojita Amanaganti successfully completed a computer science project on developing a website similar to MakeMyTrip for flights booking using Python and MySQL. It includes an index listing the various sections of the project report such as acknowledgements, aim and introduction, software and hardware used, code, output, and bibliography. The project aims to create a user-friendly application for viewing flight details and booking tickets between different cities in India by connecting to a database of flight information stored in MySQL tables.

Uploaded by

अनंत
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

KENDRIYA VIDYALAYA NO.

1 UPPAL
HYDERABAD

SUBJECT : COMPUTER SCIENCE [CS]

PROJECT TITLE : MAKE MY TRIP (FLIGHTS)

SUBMITTED BY : POOJITA AMANAGANTI

CLASS : XII A

AISSCE NO. :
KENDRIYA VIDYALAYA NO. 1 UPPAL

DEPARTMENT OF COMPUTER SCIENCE

CERTIFICATE

This is to certify that Kum. POOJITA AMANAGANTI , a


student of class XII has successfully completed the project
Programming for MAKE MY TRIP (FLIGHTS) under the
guidance of Mrs. CH. KIRAN KUMARI, PGT (C.S.) during
the year 2019-20 in partial fulfilment of computer science
practical examination conducted by AISSCE-2020.

Date :

Internal examiner External examiner Principal


INDEX

S.NO. TITLE Pg No. SIGN.

1 Acknowledgement
2 Aim and Introduction
3 Hardware and Software
4 Code
5 Output
6 Bibliography
ACKNOWLEDGEMENT

I would like to express my special thanks of gratitude to


my teacher Mrs. CH KIRAN KUMARI, PGT (C.S.) as
well as our Principal Mr. P SRINIVASA RAJU who
gave me the golden opportunity to do this wonderful
project on the topic ‘MAKE MY TRIP (FLIGHTS)’,
which also helped me in doing a lot of Research and I
came to know about so many new things I am really
thankful to them.

Secondly, I would also like to thank my family who


helped me a lot in finalizing this project within the
limited time frame.
AIM & INTRODUCTION

AIM:
To create a user friendly application that is similar to make
my trip for flights using python and mysql connectivity.

INTRODUCTION:
This project has been developed to know how websites
like www.makemytrip.com work and is written in Python.
To achieve this, Enthought Canopy v2.1.9.3717 which is
an integrated development environment and mysql 5.5
which is a relational database management system are
used.
This program allows the user to view the details of various
flights as per the source and destination, sorted and
filtered according to the user's choice and book tickets on
the basis of their availability. The tickets' prices show the
variation with date of departure and the class chosen. It
also allows the user to check their booking history.
The interactive feature of the program makes it much
more convenient for the user to get flight details and do
further booking if desired.
SOFTWARE AND HARDWARE
APPLICATION

SOFTWARE:
 ENTHOUGHT CANOPY v2.1.9.3717
 MYSQL 5.5
 MS WORD
 WINDOWS 10, 8

HARDWARE:
 4 GB RAM
 STANDARD I/O DEVICES
PREREQUISITES
CODE:
import pymysql as pmy
con=pmy.connect(host='localhost',user='root',passwd='sql')
mycursor=con.cursor()
mycursor.execute('create database flight_db;')
mycursor.execute('use flight_db;')
mycursor.execute('create table ids(id varchar(50) primary
key,Password varchar(21));')
mycursor.execute("insert into ids
values('[email protected]','password1'),('[email protected]','xyz
123');")
mycursor.execute('create table bookings(Customer_id
varchar(50),Flight_no varchar(10),Airline varchar(15),Source
varchar(20),Destination varchar(20),Class
varchar(20),No_of_passengers int(3),Date_of_departure
varchar(15),Price decimal(10,2));')
mycursor.execute('create table Flights(Flight_no varchar(10)
primary key,Airline varchar(15),Source
varchar(20),Departure_time varchar(6),Destination
varchar(20),Arrival_time varchar(6),Duration varchar(8),Price
int(10));')
#Flight_no ,Airline ,From ,Departure_time ,To , Arrival_time
,Duration ,Price
mycursor.execute("insert into flights values('6E-
121','INDIGO','HYDERABAD','22:50','CHENNAI','00:05','1h
15m',2634);")
mycursor.execute("insert into flights values('AI-
546','AIRINDIA','HYDERABAD','21:15','CHENNAI','22:15','1h
00m',2813);")
mycursor.execute("insert into flights values('SG-
732','SPICEJET','HYDERABAD','20:50','CHENNAI','21:55','1h
05m',4052);")
mycursor.execute("insert into flights values('6E-
308','INDIGO','HYDERABAD','04:35','DELHI','06:55','2h
20m',3537);")
mycursor.execute("insert into flights values('AI-
559','AIRINDIA','HYDERABAD','06:40','DELHI','08:50','2h
10m',5963);")
mycursor.execute("insert into flights values('SG-
471','SPICEJET','HYDERABAD','05:50','DELHI','08:05','2h
15m',3944);")
mycursor.execute("insert into flights values('6E-
384','INDIGO','CHENNAI','05:00','HYDERABAD','06:25','1h
25m',3752);")
mycursor.execute("insert into flights values('AI-
545','AIRINDIA','CHENNAI','19:15','HYDERABAD','20:35','1h
20m',2725);")
mycursor.execute("insert into flights values('SG-
346','SPICEJET','CHENNAI','22:30','HYDERABAD','23:35','1h
05m',3229);")
mycursor.execute("insert into flights values('6E-
212','INDIGO','CHENNAI','01:15','DELHI','04:10','2h
55m',7584);")
mycursor.execute("insert into flights values('AI-
143','AIRINDIA','CHENNAI','08:40','DELHI','11:35','2h
55m',9655);")
mycursor.execute("insert into flights values('SG-
104','SPICEJET','CHENNAI','07:00','DELHI','09:50','2h
50m',7582);")
mycursor.execute("insert into flights values('6E-
303','INDIGO','DELHI','06:40','HYDERABAD','08:55','2h
15m',3100);")
mycursor.execute("insert into flights values('AI-
560','AIRINDIA','DELHI','07:05','HYDERABAD','09:10','2h
05m',3574);")
mycursor.execute("insert into flights values('SG-
472','SPICEJET','DELHI','21:10','HYDERABAD','23:25','2h
15m',3099);")
mycursor.execute("insert into flights values('6E-
213','INDIGO','DELHI','02:05','CHENNAI','04:55','2h
50m',6624);")
mycursor.execute("insert into flights values('AI-
420','AIRINDIA','DELHI','17:20','CHENNAI','20:00','2h
40m',8194);")
mycursor.execute("insert into flights values('SG-
107','SPICEJET','DELHI','06:10','CHENNAI','09:00','2h
50m',7645);")
con.commit()
con.close()
TABLES:
Tables like below will be created/modified dynamically
during execution of program as per requirement
Functions:
difference(d): Takes the date of departure as argument and
returns the difference between this date and current date in
number of days.
date_to_tablename(d): Takes the date of departure as argument
and returns a string whose format is such that it can be accepted
as a table’s name in mysql.
create_table(tname): Takes tablename (date of departure in
mysql friendly format) as argument and creates a table with this
name having number of bookings for each flight on this date.
check_availability(tname,f_no,_class,no_p): Takes tablename
(date of departure), flight number, preferred class and number of
passengers as arguments and checks for the availability of the
seats as per the requirements and returns true or false.
count_available(tname,l_flights): Takes tablename (date of
departure) and a list of flight numbers as arguments and displays
number of available seats in these flights on that date.
ids_passwords(): Returns a dictionary of ids and their
passwords currently available in the database(flight_db).
update(tname,_class,no_p,f_no): Takes tablename(date of
departure), class(column name),number of passengers and flight
number as arguments and updates this table with the given
details.
booking(info): Takes a list of information (of a booking that is
done) as argument and inserts this information in bookings table.
CODE
from tabulate import tabulate
import pymysql as pmy
con=pmy.connect(host='localhost',user='root',passwd='sql')
mycursor=con.cursor()
mycursor.execute('use flight_db;')

def difference(d): #difference in days


from datetime import datetime,date
date=datetime.strptime(d,'%d-%m-%Y')
diff=date-datetime.now()
delta=diff.days
if delta>15:
delta=16
return delta

def date_to_tablename(d):
dd=d[:2]
mm=d[3:5]
yy=d[6:]
tname=dd+'_'+mm+'_'+yy
return str(tname)

def create_table(tname): #creates datetable


i='create table '+tname+'(Flight_no varchar(10) primary
key,Airline varchar(15),Economy int(3),Premium_economy
int(2),Business_class int(2));'
mycursor.execute(i)
mycursor.execute('select count(flight_no) from flights;')
c=mycursor.fetchone()
count=c[0]
mycursor.execute('select Flight_no,Airline from flights;')
all=mycursor.fetchall()
for i in range(count):
info=all[i]+(0,0,0)
ins='insert into '+tname+' values'+str(info)+';'
mycursor.execute(ins)
con.commit()

def check_availability(tname,f_no,_class,no_p):
i='select '+_class+' from '+tname+" where Flight_no =
'"+f_no+"';"
mycursor.execute(i)
x=list(mycursor.fetchone())
if _class=='Economy':
n=10
else:
n=5
if x[0]==None:
x[0]=0
if (n-x[0])>no_p or (n-x[0])==no_p:
return True
else:
return False

def count_available(tname,l_flights): #displays other available


options
i='select Flight_no,Airline,10-Economy,5-
Premium_economy,5-Business_class from '+tname+' where
Flight_no in '+str(l_flights)+' ;'
mycursor.execute(i)
options_=list(mycursor.fetchall())
for x in range(len(options_)):
options_[x]=list(options_[x])
for i in options_:
if i[2]==None:
i[2]=10
if i[3]==None:
i[3]=5
if i[4]==None:
i[4]=5
headers_=['Flight_no','Airline','Economy','Premium_economy
','Business_class']
table=tabulate(options_,headers_,tablefmt='psql')
print(table)
print('* Number of available seats are shown in the table')

def ids_passwords():
id_d={}
mycursor.execute('select id,password from ids;')
info=mycursor.fetchall()
for i in info:
id_d.update({i[0]:i[1]})
return id_d

def update(tname,_class,no_p,f_no): #updates datetable data


i='update '+tname+' set '+_class+'='+_class+'+'+str(no_p)+'
where Flight_no="'+f_no+'";'
mycursor.execute(i)
con.commit()

def booking(info): #adds bookings data


i='insert into bookings values '+str(info)+';'
mycursor.execute(i)
con.commit()

print('\n',' '*20,'WELCOME TO FLY IN INDIA :)')


print()
print('Being user friendly is important, press 0(zero) to exit at any
time.')
flag=0
print('\n1. Sign in \n2. Browse')
n=int(input('Choose your option : '))
while (1):
if n==0:
break
if n==1:
if flag==0: #didn't sign in
username=input('Enter username:')
if username=='0':
break
password=input('Enter password:')
if password=='0':
break
ids=ids_passwords()
if username in ids:
while ids[username]!=password:
print('Incorrect password, try again')
password=input('Enter password:')
if password=='0':
break
else:
print("\nSuccessfully signed in.")
flag=1
if password=='0':
break
print('\n1. Check booking history \n2. Browse')
a=int(input('Choose your option : '))
if a==0:
break
if a==2:
n=2
if a==1: # for booking history
i='select * from bookings where
Customer_id="'+username+'";'
mycursor.execute(i)
book=mycursor.fetchall()

headings=['Customer_id','Flight_no','Airline','Source','Destina
tion','Class','No_of_passengers','Date_of_departure','Price']
print("Here's your booking history\n")
print(tabulate(book,headings,tablefmt='psql'))
print('\n1. Browse \n2. Exit')
o=int(input('Choose your option:'))
if o==0 or o==2:
break
elif o==1:
n=2
continue

if n==2: #browse
print('\nEnter details')
print("\nList of places \n -> Hyderabad \n -> Chennai \n
-> Delhi")

f=input('Source (in capital letters): ') #from


if f=='0':
break
t=input('Destination (in capital letters): ') #to
if t=='0':
break

dep_date=input('Date of departure (DD-MM-YYYY): ')


year=int(dep_date[6:])
while year<2019:
print('Invalid date')
dep_date=input('Re-enter date of departure (DD-
MM-YYYY): ')
if dep_date=='0':
break
year=int(dep_date[6:])
if dep_date=='0':
break

date_table=date_to_tablename(dep_date)
delta=difference(dep_date)

no_passengers =int(input('\nNo. of passengers (only 5


permitted per transaction): '))
if no_passengers==0:
break
while no_passengers>5 and no_passengers!=0:
no_passengers =int(input('\nNo. of passengers
(only 5 permitted per transaction): '))
if no_passengers==0:
break

print("\n 1. Indigo \n 2. AirIndia \n 3. Spicejet \n 4.


Display all")
air_d={1:'Indigo',2:'AirIndia',3:'Spicejet'}
airline_p=eval(input("Choose a number(s) for a specific
airline or to display all \n [Example:(1,2) or 3 or 4] :"))
if airline_p==0:
break

print("\nSort by \n 1. Low to high price \n 2. High to low


price")
sort_p=int(input('Choose your option:'))
print()
if sort_p==0:
break

price='Price+'+str(16-delta)+'*0.1*Price as Price'
ft='select
Flight_no,Airline,Source,Departure_time,Destination,Arrival_time,
Duration,'+price+' from flights where source="'+f+'" and
destination="'+t+'"'
if (airline_p==1 or airline_p==2 or airline_p==3):
air=air_d[airline_p]
ft=ft+' and airline="'+air+'"'
elif airline_p==4:
ft=ft
else:
a=''
for i in airline_p:
air=air_d[i]
a=a+' or airline="'+air+'"'
ft=ft+' and ('+a[4:]+')'
if sort_p==1:
ft=ft+' order by price asc;'
else:
ft=ft+' order by price desc;'
mycursor.execute(ft)
options=mycursor.fetchall()

headers=['Flight_no','Airline','Source','Departure_time','Desti
nation','Arrival_time','Duration','Price']
table_o=tabulate(options,headers,tablefmt='psql')
print(table_o)
print('* Economy prices dispayed')
print('** +1000 for Premium economy, +2000 for
Business class')
no_options=len(options)
list_flights=()
for i in range(no_options): #list of flights displayed
above
list_flights+=(options[i][0],)
print('\n 1. Proceed for booking \n 2. Check for another
route \n 3. Exit')
next_=int(input('Choose your option:'))
if next_==0 or next_==3:
break
elif next_==2:
continue
elif next_==1:
flightno=input("Enter the flight number:")
if flightno=='0':
break
print("\nClass preference \n 1. Economy \n 2.
Premium economy \n 3. Business class")
class_d={1:'Economy',2:'Premium_economy',3:'Business_cla
ss'}
class_p=int(input('Choose your option:'))
if class_p==0:
break
class_=class_d[class_p]
mycursor.execute('show tables;')
tables=mycursor.fetchall()

myflag=0
for tup in tables:
if str(date_table)==tup[0]:
myflag=1 #datetable exists

if(myflag==1): #datetable exists


while(1):
check='select * from '+date_table+'
where flight_no="'+flightno+'";'
mycursor.execute(check)
if mycursor.fetchone(): #flightno in
datetable
if
check_availability(date_table,flightno,class_,no_passengers)==Fa
lse:
print('\nSeats unavailable!')
print('Following are more
options for you')

count_available(date_table,list_flights) #
print('\n1. Enter new details
\n2. Check another way \n3. Exit')
x=int(input('Choose your
option:'))
if x==3 or x==0:
break
elif x==2:
break
elif x==1:
flightno=input("Enter the
flight number:")
if flightno=='0':
break
print("\nClass preference
\n 1. Economy \n 2. Premium economy \n 3. Business class")

class_d={1:'Economy',2:'Premium_economy',3:'Business_cla
ss'}

class_p=int(input('Choose your option:'))


if class_p==0:
break
class_=class_d[class_p]
else:
x=-1
break
else:
x=-1
break

if x==3 or x==0 or flightno=='0' or


class_p==0:
break
if x==2:
continue

else: #if datetable doesn't exist


create_table(date_table)

for i in options: #options given to user


if i[0]==flightno:
cost=i[-1]
cost_d={1:cost,2:cost+1000,3:cost+2000}
cost_np=(cost_d[class_p])*no_passengers
cost_total=cost_np+550

if flag==0: #didn't sign in


print(' 1. Sign in \n 2. Sign up')
s=int(input('Choose your option:'))
if s==0:
break
if s==1: #sign in
username=input('Enter username:')
if username=='0':
break
password=input('Enter password:')
if password=='0':
break
ids=ids_passwords()
if username in ids:
while ids[username]!=password:
print('Incorrect password, try
again')
password=input('Enter
password:')
if password=='0':
break
else:
print("\nSuccessfully signed
in.")
if password=='0':
break
elif s==2: #sign up
username=input('Enter a username:')
if username=='0':
break
ids=ids_passwords()
while username in ids:
print('Username taken, try another
one')
username=input('Enter a
username:')
if username=='0':
break
if username=='0':
break
while(1):
password=input('Enter a
password:')
if password=='0':
break
c_password=input('Confirm
password:')
if c_password=='0':
break
if c_password!=password:
print('Incorrect input')
continue
else:
break
if c_password=='0' or password=='0':
break
i='insert into ids
values("'+username+'","'+password+'");' #to add new account
mycursor.execute(i)
con.commit()
print('\nAccount created successfully!')
flag=1
x='select airline from flights where
Flight_no="'+flightno+'";'
mycursor.execute(x)
a_=mycursor.fetchone()
airline=a_[0]

print('\n-----------------------------------')
print('Date of departure : ',dep_date)
print('\n-----------------------------------')
print('\n ',airline)
print(' FLIGHT NO : ',flightno)
print('\n From :',f,' ''To :',t)
print('\n FARE SUMMARY ')
print(' BASE FARE :',cost_np)
print(' TAXES :',550)
print(' TOTAL :',cost_total)
print('\n No.of passengers :',no_passengers)
print('-----------------------------------')
pay=input('Press enter to proceed for payment')
if pay=='0':
break
print('Payment done')

update(date_table,class_,no_passengers,flightno)
#updates datetable

print('\nTickets booked successfully, have a safe


flight!')
info_final=(username,flightno,airline,f,t,class_,no_passenger
s,dep_date,int(cost_total))
booking(info_final) #adds info in bookings

print('\n1. Want to look for more flights \n2. Check


booking history \n3. Exit')
no=int(input('Choose your option:'))

print('____________________________________________
____________________________________________________
____________________________________________________
__')
if no==0 or no==3:
break
elif no==1:
continue
elif no==2:
n,a=1,1
continue
print('\nThank you, have a good day!')
con.commit()
con.close()
OUTPUT
BIBLIOGRAPHY

I have gone through the following to complete my


project:

 Computer Science With Python Textbook For


Class XII (Sumita Arora)
 www.makemytrip.com
 www.google.com
 www.python.org
THANK YOU

You might also like