Untitled1 - Jupyter Notebook

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1/19/23, 8:53 AM Untitled1 - Jupyter Notebook

localhost:8888/notebooks/Untitled Folder/Untitled1.ipynb?kernel_name=python3 1/4


1/19/23, 8:53 AM Untitled1 - Jupyter Notebook

In [*]: import pandas as pd


import matplotlib.pyplot as plt
df1=pd.read_csv('airline_db.csv', index_col='fno')
df2=pd.read_csv('passengers.csv', index_col='pid')
def menu():
print()
print('Welcome to Bright Airways\n')
print()
print(' Press 1 for flight Booking ')
print(' Press 2 for get Passenger Information')
print(' Press 3 to check Flight Frequency')
print(' Press 0 to Exit')
print()
def get_flights():
print(df1)
def book_flight():
get_flights()
pid=int(input('Enter passanger id:'))
pname=input('Enter passenger name:')
fno=int(input('Enter flight number:'))
flightdetails = df1.loc[fno]
data = {'pid':[pid],'pname':[pname],'fno':[fno],'fare': [flightdetails['fare']],'source': [flightdetails['source']],'destinat
df = pd.DataFrame(data)
df.to_csv('passengers.csv',mode='a',header=None, index=False)
print('Flight Booked !!')

def get_passenger(pid):
df2=pd.read_csv('passengers.csv', index_col='pid')
try:
details=df2.loc[[pid]]
print(details)
except KeyError:
print('No details found')
def flight_frequency():
x=df1['destination']
y=df1['frequency']
plt.plot(x,y, color = 'g',ls=':')
plt.xlabel('destination')
plt.ylabel('frequency')
plt.title('flight frequency',fontsize = 20)
plt.show()
options=''
while(True):
menu()
options=int(input('enter your choice: '))
if options==1:
book_flight()
elif options==2:
id=int(input('Enter passenger id:'))
get_passenger(id)
elif options==3:
flight_frequency()
elif options==0:
print('Thanks for using Airline Management System')
break

localhost:8888/notebooks/Untitled Folder/Untitled1.ipynb?kernel_name=python3 2/4


1/19/23, 8:53 AM Untitled1 - Jupyter Notebook

Welcome to Bright Airways

Press 1 for flight Booking


Press 2 for get Passenger Information
Press 3 to check Flight Frequency
Press 0 to Exit

enter your choice: 1


fname source destination fare frequency
fno
1011 air india delhi mumbai 12000 2
1012 indigo delhi goa 7000 1
1013 go air delhi goa 6000 2
1014 spicejet bangalore delhi 14000 3
Enter passanger id:3489
Enter passenger name:jagdish
Enter flight number:1013
Flight Booked !!

Welcome to Bright Airways

Press 1 for flight Booking


Press 2 for get Passenger Information
Press 3 to check Flight Frequency
Press 0 to Exit

enter your choice: 3

Welcome to Bright Airways

Press 1 for flight Booking


Press 2 for get Passenger Information
Press 3 to check Flight Frequency
Press 0 to Exit

enter your choice: 2


Enter passenger id:3489
pname fno fare source destination
pid
3489 jagdish 1013 6000 delhi goa

Welcome to Bright Airways

Press 1 for flight Booking


Press 2 for get Passenger Information
Press 3 to check Flight Frequency
Press 0 to Exit

enter your choice:

In [ ]: ​

In [ ]: ​

localhost:8888/notebooks/Untitled Folder/Untitled1.ipynb?kernel_name=python3 3/4


1/19/23, 8:53 AM Untitled1 - Jupyter Notebook

localhost:8888/notebooks/Untitled Folder/Untitled1.ipynb?kernel_name=python3 4/4

You might also like