Updated Mtbs
Updated Mtbs
IN
METRO TICKET
BOOKING SYSTEM
ROLL.NO : 33
This is to certify that this project report entitled Metro Ticket Booking System is a
bonafide record of the project work done by Sai Supriya of class XII Reg.No
202230293 in the academic year 2023 – 2024. The project has been submitted in partial
I solemnly take the opportunity to thank all the helping hands who made me to complete this
project. First of all I thank the Almighty for keeping me hale and healthy in order to successfully
complete my work.
I wish to express my sincere gratitude to Dr. Fr.Lebin, Principal of Christ Academy, for permitting
me to carry out the project and for the facilities provided for the fulfilment of this project work.
I am greatly indebted to Mrs. Subhashini Thota, Teacher in Computer Science who gave me
immense support and guidance throughout the completion of this project. I express my gratitude towards
my team members for bringing out collective productivity.
Last but not the least, I express my heartiest thanks to my lovable parents and friends for their
prayers, suggestions and encouragement for the successful completion of the project.
CONTENTS
❖ ABSTRACT
❖ SYSTEM REQUIREMENTS
❖ PROJECT DESIGN
❖ DATABASE TABLES
❖ SOURCE CODE
❖ SAMPLE OUTPUT
❖ CONCLUSION
❖ BIBLIOGRAPHY
ABSTRACT
Rossum and first released in 1991, Python’s design philosophy emphasizes code readability with its
notable use of significant whitespace and indent levels. Its language constructs and object-oriented
approach aim to help programmers write clear, logical code for small and large-scale purposes.
This Project, Metro Ticket Booking System is implemented using the Python programming language,
This project is a command-line ticket booking system for a metro service. It allows users to book and
cancel tickets, view tickets booked, and put forth any suggestions or complaints. The system uses Python
programming language and SQL database management system to store and retrieve data related to tickets,
stations, schedules, payments, and suggestions. The project is designed to provide a simple and user-
friendly interface for customers to book and manage their tickets, while also providing a secure and
reliable payment system. Overall, this project demonstrates the use of programming and database
management skills to create a functional and efficient system for a real-world application.
1. `book_ticket()`: This function allows the users to book a metro ticket by selecting their starting and
2. `cancel_ticket()`: This function allows the users to cancel a previously booked ticket and calculates the
tickets.
4. `payment()`: This function allows the users to make payments using either a credit card or a debit card.
These functions work together to provide a seamless experience for users to book, manage, and cancel
RAM : 2 GB (Minimum)
4 GB (Recommended)
SOFTWARE COMPONENTS:
def is_valid_email(email):
email_regex = r'^[\w\.-]+@[\w\.-]+\.\w+$'
return re.match(email_regex, email) is not None
def is_valid_aadhaar(aadhaar):
aadhaar_regex = r'^\d{12}$'
return re.match(aadhaar_regex, aadhaar) is not None
while True:
print("Choose to:")
print("1. Sign up")
print("2. Sign in")
choce = int(input())
if choce == 1:
name = input("Enter your name:")
email = input("Enter your email: ")
password = input("Enter your password: ")
sql = "INSERT INTO users (name, email, password) VALUES ( %s, %s, %s)"
val = (name, email, password)
mycursor.execute(sql, val)
mydb.commit()
print("You have signed up successfully")
if not user:
print("Email not found. Please try again.")
continue
if not user:
print("Email not found. Please try again.")
continue
if choice == 1:
print('''The available stations are:
1.Geeta Nagar
2.Gurudev Chauraha
3.IIT Kanpur
4.Kalyanpur
5.LLR Hospital
6.Moti Jheel
7.Rawatpur
8.SPM Hospital
9.Vishwavidyalaya''')
start_station = input("Enter your starting station: ").title()
dest_station = input("Enter your destination station: ").title()
if not is_valid_aadhar(aadhar):
print("Invalid Aadhar number. Please try again.")
continue
sql = "SELECT departure_time FROM schedules WHERE start_station = %s AND dest_station = %s"
val = (start_station, dest_station)
mycursor.execute(sql, val)
departure_time = mycursor.fetchone()
if departure_time:
print("Departure time: ", departure_time[0])
else:
print("No schedule found for the selected stations.")
if confirm == "yes":
# Calculate fare for each passenger
fare = 0
for passenger in passenger_details:
age = passenger["age"]
if age >= 60 or age < 12:
fare += 0.5 * 10 # Apply 50% discount for senior citizens and children
else:
fare += 10
def payment():
global fare
print("\nPayment Details:")
print("Total Amount to be Paid:", fare)
print("1. Use Credit score")
print("2. Pay with Credit Card")
print("3. Pay with Debt Card")
print("4. Pay with atm")
if choice == 1:
sql = "Select count(user_id) from tickets where user_id ={}".format(user[0])
mycursor.execute(sql)
ticket = mycursor.fetchall()
print("You have", ticket, "credentials")
s = [(5,)]
if ticket < s:
print("You do not have sufficient credentials")
payment()
else:
a = input("Do you want to use them?(yes/no): ")
if a == 'yes':
if ticket > s:
fare -= 0.1 * 10
print("Your fare is:", fare)
else:
print("Not applicaple")
else:
payment()
elif choice == 4:
atm_number = input("Enter ATM account number: ")
print("enter the bank name in lower case")
bank_name = input("Enter bank name ['icici', 'hdfc', 'axis', 'sbi']")
# Check if ATM account number is valid
if len(atm_number) != 10 or not atm_number.isdigit():
print("Invalid ATM account number. Please try again.")
# Check if bank name is valid
elif bank_name.lower() not in ["icici", "hdfc", "axis", "sbi"]:
print("Invalid bank name. Please try again.")
else:
print("\nInvalid choice. Please try again.")
return
payment()
elif choice == 2:
ticket_id = int(input("Enter the ticket ID: "))
mycursor.execute(sql)
ticket = mycursor.fetchone()
s = int(ticket[4])
if not ticket:
print("Invalid ticket number.")
elif ticket[6] == "cancelled":
print("Ticket has already been cancelled.")
else:
print("Time:", ticket[5])
booking_time = ticket[5]
departure_time = booking_time + timedelta(minutes=30)
time_before_departure = departure_time - datetime.datetime.now()
mycursor = mydb.cursor()
sql = "UPDATE tickets SET status = %s WHERE id = %s"
val = (status, ticket_id)
mycursor.execute(sql, val)
mydb.commit()
cancellation_time = datetime.datetime.now()
mycursor = mydb.cursor()
sql = "INSERT INTO cancellations (ticket_id, cancellation_time, refund) VALUES (%s, %s, %s)"
val = (ticket_id, cancellation_time, refund)
mycursor.execute(sql, val)
mydb.commit()
elif choice == 3:
sql = "Select * from tickets where user_id ={}".format(user[0])
mycursor.execute(sql)
ticket = mycursor.fetchall()
if ticket is not None:
for i in ticket:
s = ticket.index(i)
print('_'*40)
print('\n','Ticket ID =', ticket[s][0],'\n', "User ID =", ticket[s][1],'\n', "Start Station =", ticket[s][2],'\n',
"Destination Station =", ticket[s][3],'\n', "Fare =", ticket[s][4],'\n', "Booking time =", ticket[s][5],'\n', "Status =",
ticket[s][6],'\n')
print('_'*40)
else:
print('You need to book tickets to view history')
elif choice == 4:
sql = "Select count(user_id) from tickets where user_id ={}".format(user[0])
mycursor.execute(sql)
ticket = mycursor.fetchall()
t = [(5,)]
if ticket > t:
print("You have", ticket, "credit score")
else:
print("You need to have booked at least", t, "times to obtain credit score")
elif choice == 5:
feedback_types = input("Enter 'S' for suggestion or 'C' for complaint: ")
if feedback_types.upper() == "S":
feedback_types = "Suggestion"
elif feedback_types.upper() == "C":
feedback_types = "Complaint"
else:
print("Invalid feedback type. Please try again.")
continue
print("\nThank you for your " + feedback_types.lower() + "! We appreciate your feedback.")
elif choice == 6:
print("Thank you for using Kanpur Metro!")
break
else:
print("Invalid choice. Please try again.")
SAMPLE OUTPUTS
CONCLUSION
In conclusion, the metro ticket booking system is a useful application that allows users to
book and cancel metro tickets, view their booking history, and make payments using credit or
debit cards. The system is designed to be user-friendly and efficient, with a simple interface
The system uses a database to store information about metro, stations, and bookings, and also
includes features such as cancellation policies and refund calculations. Overall, the metro
ticket booking system is a practical and effective solution for people who want to book metro
While this project provides a good foundation for a metro ticket booking system, there are still
many areas where it can be improved. For example, the system could be enhanced by adding
more advanced features such as seat selection, metro schedule information, and real-time
status updates. Additionally, the user interface could be made more visually appealing and
Benefits/Advantages:
- Provides a simple and efficient way to book and cancel metro tickets.
Drawbacks:
- There is no authentication system for user accounts, which can make the system vulnerable
to hacking.
- The payment system is not integrated with any payment gateway, which could be a
- The addition of an authentication system could make the system more secure and reliable.
- The project could also be extended to cover more routes and stations.
Future Enhancements:
- Integration with GPS tracking to provide real-time metro tracking and arrival/departure
times.
- Addition of a mobile application to make ticket booking and cancellation more accessible
BIBLIOGRAPHY
—› Computer Science with Python (Textbook for Class XII) by Sumita Arora
—› https://github.com
—+ https://codemy.com
—› https://www.geeksforgeeks.org
—+ https://stackoverflow.com