Ip Project File
Ip Project File
M PUBLIC SCHOOL
SESSION 2024-2025
IP PROJECT WORK
SUBMITTED BY :- SUBMITTED TO :-
NAME : OJASHWA KATIYAR
CLASS :XII ‘B’
ROLL NO.:
CERTIFICATE
SIGNATURE OF EXAMINER
CONTENTS
1. DECLARATION
2. ACKNOWLEDGMENT
3. SOFTWARE REQUIREMENTS
4. HARDWARE REQUIREMENTS
5. INTRODUCTION
6. TABLE STRUCTURE
7. PYTHON CODE
8. INPUT/OUTPUT INTERFACE
9. BIBLIOGRAPHY
ACKNOWLEDGEMENT
I would like to express my deep sense of gratitude to my project guide, Ms. Sangeeta Belwal
ma’am , for her invaluable guidance throughout the course of this project. Her keen interest in
my work, constructive advice, and constant motivation have been instrumental in the
successful completion of this project.
I also extend my heartfelt thanks to my parents for their unwavering support and
encouragement. Additionally, I am grateful to my classmates for their timely help and
support, which significantly contributed to the completion of this project.
Lastly, I would like to thank everyone who directly and indirectly assisted me in completing
this project.
SOFTWARE REQUIREMENTS
To implement and run the railway reservation system effectively, several software
requirements need to be considered. These requirements ensure that the system operates
smoothly, securely, and efficiently. Below are the detailed software requirements categorized
into different sections.
1. Operating System
➢ Windows: Windows 10 or later
➢ Linux: Ubuntu 18.04 or later, or equivalent distributions
➢ macOS: macOS Mojave (10.14) or later
2. Programming Language
➢ Python: Version 3.7 or later
3. Development Environment
➢ Integrated Development Environment (IDE):
• PyCharm
• Visual Studio Code
• Jupyter Notebook (for initial prototyping and testing)
4. Database
➢ MySQL: Version 5.7 or later
• MySQL Connector for Python: mysql-connector-python
5. Libraries and Packages
➢ Standard Python Libraries:
• ‘os’: For operating system dependent functionality
• ‘random’: For generating random numbers
➢ Third-Party Libraries:
• mysql-connector-python: To connect and interact with the MySQL database
• matplotlib: For generating analytics plots and visualizations
• datetime: For handling date and time-related functionalities
7. Security
➢ Password Management: Secure handling and storage of admin passwords (consider
hashing passwords for added security)
➢ Input Validation: Proper validation of user inputs to prevent SQL injection and other
common security vulnerabilities
8. User Interface
➢ CLI (Command Line Interface): Initially, the system will use a CLI for interaction with
users
➢ Future Enhancements: Consider implementing a graphical user interface (GUI) using
frameworks like Tkinter, PyQt, or a web-based interface using Flask or Django
9. Version Control
➢ Git: For source code management and version control
➢ Repository Hosting: GitHub, GitLab, or Bitbucket
10. Documentation
➢ Project Documentation: Including user guides, developer documentation, and API
documentation
➢ Docstrings: Inline documentation within the code for better maintainability
11. Testing
➢ Unit Testing Framework: unittest or pytest for creating and running tests
➢ Database Testing: Scripts for testing database interactions
HARDWARE REQUIREMENTS
To ensure the railway reservation system runs efficiently and effectively, here are the minimum and
recommended hardware requirements:
Outputs:
• User Interface: Displays a menu with various options for different operations.
• Booking Confirmation: Shows a confirmation message with the PNR number upon
successful ticket booking.
• Train Lists: Lists of available trains based on user input.
• Booked Ticket Details: Displays details of booked tickets when provided with a PNR
number.
• Cancellation Confirmation: Confirms ticket cancellation.
• Analytics Visualizations: Generates plots related to train data.
➢ DBMS: MySQL
➢ Host: localhost
➢ User: root
➢ Password: root
➢ DataBase: class12project
while True:
a1=input("Enter the Admin Password Of Railway Reservation.: ")
if a1=='v3nom@123':
print("Logging in...")
try:
import mysql.connector as msc
import datetime
import random as rd
import pandas as pd
import sys
import matplotlib.pyplot as plt
#v3nom 2024-2025
mydb=msc.connect(host="localhost",
user="root",
password="root",
)
crs=mydb.cursor()
qry01="CREATE DATABASE IF NOT EXISTS Class12Project"
crs.execute(qry01)
qry02="USE Class12Project"
crs.execute(qry02)
qry1 = "INSERT INTO avail_Train VALUES (1001, 12847, 'Howrah - Digha SUPER
AC Express', 'Howrah', 'Digha', 50.00) ON DUPLICATE KEY UPDATE Train_No = 12847,
fare = 50.00"
qry1 = "INSERT INTO avail_Train VALUES (1001, 12847, 'Howrah - Digha SUPER
AC Express', 'Howrah', 'Digha', 50.00) ON DUPLICATE KEY UPDATE Train_No = 12847,
fare = 50.00"
qry2 = "INSERT INTO avail_Train VALUES (1002, 12009, 'Mumbai Central -
Ahmedabad Shatabdi Express', 'Mumbai', 'Ahmedabad', 75.00) ON DUPLICATE KEY
UPDATE Train_No = 12009, fare = 75.00"
qry3 = "INSERT INTO avail_Train VALUES (1003, 120010, 'New Delhi - Lucknow
Jn Swarn Shatabdi Express', 'New Delhi', 'Lucknow', 60.00) ON DUPLICATE KEY UPDATE
Train_No = 120010, fare = 60.00"
qry4 = "INSERT INTO avail_Train VALUES (1004, 1280050, 'New Delhi - Amritsar
Shatabdi Express', 'New Delhi', 'Amritsar', 65.00) ON DUPLICATE KEY UPDATE Train_No =
1280050, fare = 65.00"
qry5 = "INSERT INTO avail_Train VALUES (1005, 1282371, 'New Delhi - Daurai
(Ajmer) Shatabdi Express', 'New Delhi', 'Ajmer', 80.00) ON DUPLICATE KEY UPDATE
Train_No = 1282371, fare = 80.00"
qry6 = "INSERT INTO avail_Train VALUES (1006, 1204745, 'Howrah - Ranchi
Shatabdi Express', 'Digha', 'Ranchi', 55.00) ON DUPLICATE KEY UPDATE Train_No =
1204745, fare = 55.00"
qry7 = "INSERT INTO avail_Train VALUES (1007, 1284769, 'KSR Bengaluru -
MGR Chennai Central Shatabdi Express', 'Bengaluru', 'Chennai', 70.00) ON DUPLICATE
KEY UPDATE Train_No = 1284769, fare = 70.00"
qry8 = "INSERT INTO avail_Train VALUES (1008, 1201789, 'New Delhi - Kanpur
Central Shatabdi Express', 'New Delhi', 'Kanpur', 45.00) ON DUPLICATE KEY UPDATE
Train_No = 1201789, fare = 45.00"
qry9 = "INSERT INTO avail_Train VALUES (1009, 100052, 'MGR Chennai Central -
Coimbatore Shatabdi Express', 'Chennai', 'Coimbatore', 50.00) ON DUPLICATE KEY
UPDATE Train_No = 100052, fare = 50.00"
qry10 = "INSERT INTO avail_Train VALUES (1010, 1286565, 'New Delhi -
Chandigarh Shatabdi Express', 'New Delhi', 'Chandigarh', 55.00) ON DUPLICATE KEY
UPDATE Train_No = 1286565, fare = 55.00"
qry11 = "INSERT INTO avail_Train VALUES (1011, 101285, 'Pune - Secunderabad
Shatabdi Express', 'Pune', 'Secunderabad', 60.00) ON DUPLICATE KEY UPDATE Train_No
= 101285, fare = 60.00"
qry12 = "INSERT INTO avail_Train VALUES (1012, 100212, 'New Delhi - Firozpur
Cantt Shatabdi Express', 'New Delhi', 'Firozpur', 65.00) ON DUPLICATE KEY UPDATE
Train_No = 100212, fare = 65.00"
qry13 = "INSERT INTO avail_Train VALUES (1013, 130201, 'New Delhi - Jammu
Tawi Rajdhani Express', 'New Delhi', 'Jammu', 75.00) ON DUPLICATE KEY UPDATE
Train_No = 130201, fare = 75.00"
qry14 = "INSERT INTO avail_Train VALUES (1014, 111000, 'KSR Bengaluru -
Hazrat Nizamuddin Rajdhani Express', 'Bengaluru', 'Hazrat Nizamuddin', 85.00) ON
DUPLICATE KEY UPDATE Train_No = 111000, fare = 85.00"
qry15 = "INSERT INTO avail_Train VALUES (1015, 100005, 'M.G.R Chennai
Central - Hazrat Nizamuddin Rajdhani Express', 'Chennai', 'Hazrat Nizamuddin', 90.00) ON
DUPLICATE KEY UPDATE Train_No = 100005, fare = 90.00"
qry16 = "INSERT INTO avail_Train VALUES (1016, 104040, 'New Delhi - Ranchi
Rajdhani Express', 'New Delhi', 'Ranchi', 95.00) ON DUPLICATE KEY UPDATE Train_No =
104040, fare = 95.00"
qry17 = "INSERT INTO avail_Train VALUES (1017, 121546, 'MGR Chennai Central
- Thiruvananthapuram Central', 'Chennai', 'Thiruvananthapuram', 100.00) ON DUPLICATE
KEY UPDATE Train_No = 121546, fare = 100.00"
qry18 = "INSERT INTO avail_Train VALUES (1018, 141524, 'Mumbai LTT -
Haridwar AC Express (PT)', 'Mumbai', 'Haridwar', 105.00) ON DUPLICATE KEY UPDATE
Train_No = 141524, fare = 105.00"
qry19 = "INSERT INTO avail_Train VALUES (1019, 152634, 'Bhuj - Mumbai
Bandra (T.) AC SuperFast Express', 'Bhuj', 'Mumbai', 110.00) ON DUPLICATE KEY UPDATE
Train_No = 152634, fare = 110.00"
qry20 = "INSERT INTO avail_Train VALUES (1020, 136524, 'Lucknow - New Delhi
AC Superfast Express', 'Lucknow', 'New Delhi', 115.00) ON DUPLICATE KEY UPDATE
Train_No = 136524, fare = 115.00"
qry31 = "INSERT INTO avail_Train VALUES (1021, 1201546, 'Nagpur - Amritsar
AC SF Express', 'Nagpur', 'Amritsar', 120.00) ON DUPLICATE KEY UPDATE Train_No =
1201546, fare = 120.00"
qry32 = "INSERT INTO avail_Train VALUES (1022, 126352, 'Arunachal AC SF
Express', 'New Delhi', 'Itanagar', 125.00) ON DUPLICATE KEY UPDATE Train_No = 126352,
fare = 125.00"
qry33 = "INSERT INTO avail_Train VALUES (1023, 104152, 'Darshan Express',
'Howrah', 'Digha', 130.00) ON DUPLICATE KEY UPDATE Train_No = 104152, fare = 130.00"
qry34 = "INSERT INTO avail_Train VALUES (1024, 100525, 'Visakhapatnam -
Secunderabad AC SF Express', 'Visakhapatnam', 'Secunderabad', 135.00) ON DUPLICATE
KEY UPDATE Train_No = 100525, fare = 135.00"
qry35 = "INSERT INTO avail_Train VALUES (1025, 100121, 'Patna - Ranchi AC
Express', 'Patna', 'Ranchi', 140.00) ON DUPLICATE KEY UPDATE Train_No = 100121, fare
= 140.00"
qry36 = "INSERT INTO avail_Train VALUES (1026, 114754, 'Barmer - Yesvantpur
AC Express', 'Barmer', 'Yesvantpur', 145.00) ON DUPLICATE KEY UPDATE Train_No =
114754, fare = 145.00"
qry37 = "INSERT INTO avail_Train VALUES (1027, 128474, 'Jammu Tawi -
Ahmedabad Express', 'Jammu Tawi', 'Ahmedabad', 150.00) ON DUPLICATE KEY UPDATE
Train_No = 128474, fare = 150.00"
qry38 = "INSERT INTO avail_Train VALUES (1028, 128654, 'Jammu Tawi -
Guwahati Amarnath Express (PT)', 'Jammu Tawi', 'Guwahati', 155.00) ON DUPLICATE KEY
UPDATE Train_No = 128654, fare = 155.00"
qry39 = "INSERT INTO avail_Train VALUES (1029, 1280417, 'Bandra Terminus -
Gorakhpur Avadh Express (PT)', 'Mumbai', 'Gorakhpur', 160.00) ON DUPLICATE KEY
UPDATE Train_No = 1280417, fare = 160.00"
qry40 = "INSERT INTO avail_Train VALUES (1030, 124557, 'Dibrugarh - Amritsar
Weekly Express (PT)', 'Dibrugarh', 'Amritsar', 165.00) ON DUPLICATE KEY UPDATE
Train_No = 124557, fare = 165.00"
crs.execute(qry1)
crs.execute(qry2)
crs.execute(qry3)
crs.execute(qry4)
crs.execute(qry5)
crs.execute(qry6)
crs.execute(qry7)
crs.execute(qry8)
crs.execute(qry9)
crs.execute(qry10)
crs.execute(qry11)
crs.execute(qry12)
crs.execute(qry13)
crs.execute(qry14)
crs.execute(qry15)
crs.execute(qry16)
crs.execute(qry17)
crs.execute(qry18)
crs.execute(qry19)
crs.execute(qry20)
crs.execute(qry31)
crs.execute(qry32)
crs.execute(qry33)
crs.execute(qry34)
crs.execute(qry35)
crs.execute(qry36)
crs.execute(qry37)
crs.execute(qry38)
crs.execute(qry39)
crs.execute(qry40)
mydb.commit()
crs.close()
print("""
_ __
| |\ | | \ | | | |\ | | || | | | | | | |\ /| |
| |\ || | | | ||\ | | || | | | | | | | \_ / |
| | \|| | | | ||\| |\ | | | | | /\ | | | | |
| | \| | / | | | | \| |\ | | | | |/ \| | | | | |
""")
d=datetime.date.today()
t=datetime.datetime.now()
print(" ")
print(" ")
print(" DATE:-",d.strftime("%A, %d %B %Y"))
print(" ")
print(" TIME:-",t.strftime("%H:%M:%S"))
print("")
print('')
print(" ")
print("
=======================================================================
==========================================================")
print(" WELCOME TO RAILWAY
RESERVATION PORTAL")
print("
=======================================================================
==========================================================")
print(" ")
while True:
#v3nom 2024-2025
print("""
***************************** DASHBOARD
********************************
+ +
| 1. ADMIN ACCESS |
+ +
+ +
| 2. CREATORS |
+ +
+ +
| 3. EXIT |
+--------------------------------+ """)
break
def railsmenu():
print("""
+====================================+
| **** MAIN MENU **** |
+====================================+
| |
| 1. Ticket Booking |
| 2. Train Between Stations |
| 3. Train List |
| 4. Your Ticket |
| 5. Ticket Cancellation |
| 6. Analytics |
| 7. Exit |
| |
+====================================+
""")
#break
x=int(input("""YOUR OPTION:- """))
#v3nom 2024-2025
if x==1:
ticket_booking()
#v3nom 2024-2025
elif x==2:
print(" ")
print(btw_Stations())
#v3nom 2024-2025
elif x==3:
print(" ")
print("-----FOLLOWING TRAINS ARE AVAILABLE ---- ")
print(" ")
print(Available_ALL_Trains())
#v3nom 2024-2025
elif x==4:
print(" ")
print(self_booked_ticket())
#v3nom 2024-2025
elif x==5:
print(" ")
print(ticket_cancellation())
#v3nom 2024-2025
elif x==6:
print(" ")
print(Analytics())
#v3nom 2024-2025
elif x==7:
print(" ")
print("\n"
" \n"
"
##======================================================##\n"
" || THANK YOU ||\n"
"
##======================================================##\n"
"\n")
print('''
else:
print(" ")
print("~!~!~!~WRONG CHOICE PLEASE ENTER A VALID
VALUE~!~!~!~")
return("")
def ticket_booking():
import mysql.connector
import re
#v3nom 2024-2025
mydb = mysql.connector.connect(
host='localhost',
user='root',
password="root",
database='Class12Project'
)
#v3nom 2024-2025
crs = mydb.cursor()
mydb.autocommit = True
Psn_Name = input('Enter your Full Name.: ')
def Available_ALL_Trains():
import mysql.connector as msc
mydb=msc.connect(host='localhost',user='root',passwd='root',database='Class12Project')
crs=mydb.cursor()
mydb.autocommit=True
crs.execute("use Class12Project")
qry="Select * from avail_train "
crs.execute(qry)
data1 = crs.fetchall()
#v3nom 2024-2025
df = pd.DataFrame(data1,
columns=["Srno","Train_No","Train_Name","Train_from","Train_to","Fare",])
print(df)
mydb.commit()
crs.close()
return("")
def btw_Stations():
import mysql.connector as msc
mydb = msc.connect(host='localhost', user='root', passwd='root',
database='Class12Project')
crs = mydb.cursor()
#v3nom 2024-2025
mydb.autocommit = True
crs.execute("USE Class12Project")
#v3nom 2024-2025
def self_booked_ticket():
import mysql.connector as msc
mydb = msc.connect(host='localhost', user='root', passwd='root',
database='Class12Project')
crs = mydb.cursor()
mydb.autocommit = True
Self_Pnr = int(input('Enter your Pnr_number No: '))
crs.execute('SELECT * FROM passenger_details WHERE Pnr_Number = (%s)',
(Self_Pnr,))
data = crs.fetchall()
if not data:
print('~!~!~!~!~~NO DATA FOUND~~!~!~!~!~')
return pd.DataFrame()
else:
df = pd.DataFrame(data, columns=columns)
print(df)
mydb.commit()
return ""
#v3nom 2024-2025
def ticket_cancellation():
import mysql.connector as msc
mydb=msc.connect(host='localhost',user='root',passwd='root',database='Class12Project')
crs=mydb.cursor()
mydb.autocommit=True
crs.execute("use Class12Project")
Self_Pnr=int(input("Enter Your Pnr_Number.:"))
Self_Name=input("Enter Your Name.:")
Self_Phno=int(input("Enter You Phone no.:"))
#qry='DELETE FROM passenger_details WHERE Pnr_Number=(%s) or
Psn_Name=(%s) or Psn_Ph_no=(%s)'
else:
print(" Ticket NOT Cancelled")
#v3nom 2024-2025
print("")
print(" Your Ticket is Cancelled")
return("")
#v3nom 2024-2025
def Analytics():
print("""
+=====================================================+
| **** MAIN MENU **** |
+=====================================================+
| |
| 1. BAR PLOT :- Fare of Passengers |
| 2. LINE PLOT :- AC Fare Of Trains |
| 3. BAR PLOT :- Sleeper Fare Of Trains |
| 4. LINE PLOT :- Average Distance Covered By Train |
| |
+=====================================================+
""")
opt=int(input(""" YOUR OPTION:-"""))
#v3nom 2024-2025
if opt==1:
print(" ")
print(bar_plot())
elif opt==2:
print(" ")
print(line_plot())
elif opt==3:
print(" ")
print(barh_plot())
elif opt==4:
print(" ")
print(line1_plot())
else:
print(" ")
print("~!~!~!~WRONG CHOICE PLEASE ENTER A VALID
VALUE~!~!~!~")
#v3nom 2024-2025
def bar_plot():
plt.figure(figsize=(9,6))
plt.bar(x=["YUSUF","ZAINAB","AHMED","AISHA","FATIMA","HASSAN","ZARA"],
height=[32,95,59,65,75,112,75],color='midnightblue')
plt.xticks(rotation=45)
plt.title("Fare of Passengers")
plt.savefig("Fare of Passengers.png")
plt.show()
return("")
#v3nom 2024-2025
def line_plot():
print("Line Plot")
x=["Goa Express","JammuTavi Superfast","Punjab Mail
Express","Dakshin Express","Delhi-Mumbai Shatabdi"]
y=[70,90,110,140,180]
plt.title("AC Fare Of Trains",fontsize=14,color="g")
plt.xlabel("Trains",fontsize=14,color="g")
plt.ylabel("AC Fare",fontsize=14,color="g")
plt.xticks(rotation=12)
if e=="1" :
print(railsmenu())
#v3nom 2024-2025
elif e=="2":
print(" ")
print( '''
_
|\ \|\ \|\ \ |\ \|\ \\ \|\ \|\ \
\\ \ |\ \ \|\ \ \ /|\ \ \|\ \| \ \_\ \ \|\ \ \ \|\ \ \ \ |_
\ \ \ \ \ _ _\ \ \_|/_\ \ \ \\ \ \ \ \\\ \ \ _ _\ \ \
\\ \ \ \ \\ \\ \ \_|\ \ \ \ \ \ \\ \ \ \ \\\ \ \ \\ \\| |\ \
\\ \ \__\\ _\\ \ \\ \ \__\ \ \ \ \ \ _\ \ \\ _\ \_\ \
\| |\|__|\| |\| |\| |\| | \| | \| _|\| |\| |\ _\
=======================================================================
==========================================================
20. DANESH FAISAL
=======================================================================
==========================================================
Responsibilities: I was responsible for writing the code and generating the output for the
project. This involved designing the algorithm, implementing the code, debugging, and
ensuring that the final program ran smoothly and met all the specified requirements.
=======================================================================
==========================================================
21. ZAKI SAJID HAWALDAR
=======================================================================
==========================================================
Role: Writing
Responsibilities: Zaki handled the writing part of the project. This included creating the project
report, documenting the code, explaining the methodology, and providing a detailed analysis
of the results. Their work ensured that our project was well-documented and that all aspects
of our approach were clearly communicated.
=======================================================================
==========================================================
3. SALMAN RIYAS
=======================================================================
==========================================================
Role: Editing
Responsibilities: Salman took on the editing tasks. This involved reviewing the written content
for clarity, coherence, and grammatical accuracy. They also ensured that the final document
was polished, well-organized, and free from errors, enhancing the overall quality and
professionalism of our project.
''')
elif e=="3":
print(" ")
print("\n"
" \n"
"
##======================================================##\n"
" || THANK YOU ||\n"
"
##======================================================##\n"
"\n")
print('''
23. www.python.com
24. www.mysql.com
25. chat.openai.com