0% found this document useful (0 votes)
31 views3 pages

Source Code AP

This document contains a Python program for booking bus tickets in Gorakhpur, India. The program allows the user to select a destination, number of passengers, enter passenger details and see a total price. It tracks available seats and provides discounts for children and seniors.

Uploaded by

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

Source Code AP

This document contains a Python program for booking bus tickets in Gorakhpur, India. The program allows the user to select a destination, number of passengers, enter passenger details and see a total price. It tracks available seats and provides discounts for children and seniors.

Uploaded by

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

# bus ticket booking program

# this program will work for GORAKHPUR only


# total seats available=48

# _____________WELCOME message_____________
print('\n')
print(('-' * 52).center(108))
print('| Welcome to Gorakhpur Bus Ticket Booking program |'.center(108))
print(('-' * 52).center(108))
print('\n\n\nWe will provide you --- * 35% discount on tickets booked for senior
citizen (60+ y/o)\n'
'\t\t\t\t\t\t* 50% discount on tickets booked for children between age 5 to
10\n'
'\t\t\t\t\t\t* Free travel for children of age below or equal to 5\n\n')

# FIXED DATAS
city_list = {1: 'LUCKNOW', 2: 'VARANASI', 3: 'NOIDA', 4: 'AGRA'}
price = {'LUCKNOW': 719, 'VARANASI': 334, 'NOIDA': 1248, 'AGRA': 899}
yes = ['yes', 'YES', 'Yes', 'YeS', 'Yess', 'y', 'ha', 'ji', 'offcourse', 'y',
'yeah', 'yupp', 'yy', 'YY']
male = ['MALE', 'M', 'MEN', 'MAN', 'GENTS']
female = ['FEMALE', 'F', 'WOMAN', 'WOMEN', 'LADIES', 'LADY']
done = 'no'
k = ""
seat_left = 48
Seats = 0
allPASSENGERS = {}

# selecting destination
while done not in yes:
print(
'Select your destination city\nPress 1 for LUCKNOW\t\tRs. 719 per person\
nPress 2 for VARANASI\t\tRs. 334 per '
'person '
'\nPress 3 for NOIDA\t\tRs. 1248 per person\nPress 4 for AGRA\t\tRs. 899
per person')
x = int(input('\n'))
if x not in [1, 2, 3, 4]:
print("You chosen wrong!!!")
city = city_list[x]
price_for_one_ticket = price[city]

print('\n')

print('total seats available =', seat_left - Seats)

q = input('\nare you going to travel alone? \nYes/No : ')


if q in yes:
Seats = 1
else:
Seats = int(input('\nHow many people have to book Seats : '))
# print('\n')
# print('\n')

if Seats <= seat_left:


passengers = {}
for allInfo in range(1, Seats + 1):
d = []
print('\nEnter Name of passenger', allInfo)
name = input()
name = name.capitalize()
print('\ngender of', name)
gender = input('Male/Female : ')
gender = gender.upper()
if gender in male:
print('\nwhat is age of Mr.', name)
elif gender in female:
print('\nwhat is age of Miss.', name)
else:
print('\nwhat is age of', name)
age = int(input())
d.append(age)
d.append(gender)
passengers[name] = d

# print('\n')

print("\nPlease verify the following information")


print('\n')
print('You are booking', Seats, 'Seats\nDetails are given below --')

for details in passengers:


if passengers[details][1] in male:
print("Mr.", details, "whose age is", passengers[details][0])
elif passengers[details][1] in female:
print("Miss", details, "whose age is", passengers[details][0])
else:
print(details, "whose age is", passengers[details][0])
if Seats > 1:
print("\nYou are booking Bus ticket for them to", city)
else:
print("You are booking Bus ticket to go", city)
ask = input('Are all these details correct??\nYes/No\t')

p = []
# ______amount______
for aadmi in passengers:
if passengers[aadmi][0] <= 5:
p.append(0)
elif 5 < (passengers[aadmi][0]) <= 10:
e = price_for_one_ticket * 0.5
p.append(e)
elif passengers[aadmi][0] >= 60:
e = price_for_one_ticket - (0.35 * price_for_one_ticket)
p.append(e)
else:
e = price_for_one_ticket
p.append(e)

amount = sum(p)
if ask in yes:
print("total price which you will have to pay would be :",
int(amount), "Rupees Only")
print('\nThanks for booking ticket through our program\nWishing you a
very happy journey')
seat_left = seat_left - Seats
allPASSENGERS[seat_left] = passengers
else:
print('All previously given data is deleted\nYou can redo the process
if you want')

else:
print('Not this many seats left')
done = 'no'

print('\n\n')
if seat_left != 0:
done = input('Do you want to close the program??\nYes/No : ')

# _________if we want to print all information_________

print("ThankYou for using this program to book tickets\n",


"If You want to get all data of tickets booked here, press \'F\'")
try:
k = input()
if k.isalpha():
k = k.upper()
else:
pass
except Exception as exp:
print(exp)

if k == 'F':
for data in allPASSENGERS:
print('-' * 48)
print(48 - data, 'Seats are booked by\n')
for detailedData in allPASSENGERS[data]:
if allPASSENGERS[data][detailedData][1] in male:
print('Mr.', detailedData, ', age', allPASSENGERS[data]
[detailedData][0])
elif allPASSENGERS[data][detailedData][1] in female:
print('Miss.', detailedData, ', age', allPASSENGERS[data]
[detailedData][0])
else:
print(detailedData, ', age', allPASSENGERS[data][detailedData][0])

You might also like