[go: up one dir, main page]

0% found this document useful (0 votes)
160 views45 pages

Ip Project

The document describes a Python program that simulates a railway reservation system. The system allows users to book tickets, view train schedules, cancel reservations, and analyze travel data. It features a menu-driven interface, ticket booking confirmation with PNR numbers, train listings, reservation details lookup, ticket cancellation, and data analytics generation.

Uploaded by

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

Ip Project

The document describes a Python program that simulates a railway reservation system. The system allows users to book tickets, view train schedules, cancel reservations, and analyze travel data. It features a menu-driven interface, ticket booking confirmation with PNR numbers, train listings, reservation details lookup, ticket cancellation, and data analytics generation.

Uploaded by

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

DOHA MODERN INDIAN SCHOOL

INFORMATICS PRACTICES
PROJECT FILE
SESSION 2024-25

CLASS: - XII

PREPARED BY: - TEAM V3NOM GUIDED BY: -


 DANESH FAISAL MS. REKHA
 ZAKI SAJID HAWALDAR
 SALMAN RIYAS
CERTIFICATE

The project report titled "RAILWAY RESERVATION SYSTEM," authored by Team V3NOM
from Class XII 'AB,' has undergone thorough examination for the CBSE Senior
Secondary Examination 2024-25 in Informatics Practices at Doha Modern Indian
School. The report presents a comprehensive study on the development and
implementation of a railway reservation system. Through meticulous analysis and practical
application, the team has demonstrated proficiency in software development and
database management, showcasing their skills in Informatics Practices. The examination
process involved evaluating the project's methodology, functionality, and adherence to
academic standards. Team V3nom's dedication and proficiency in tackling the
complexities of designing a reservation system for the railway sector have been duly
noted and appreciated. The examination outcome reflects the team's commitment to
academic excellence and their ability to apply theoretical knowledge to real-world
scenarios effectively.

SIGNATURE OF EXAMINER

1 V3NOM
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

2 V3NOM
DECLARATION

I hereby declare that the project work entitled “Railway Reservation System”, submitted to
Department of Informatic practices, Doha Modern Indian School, is prepared by us.

1. DANESH FAISAL (CLASS XII-B)


Role: Coding and Output
Responsibilities: Danesh 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.

2. ZAKI SAJID HAWALDAR (CLASS XII-B)


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 (CLASS XII-A)


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.

3 V3NOM
ACKNOWLEDGEMENT

We would like to express our deep sense of gratitude to our project guide, Ms. Rekha, for her
invaluable guidance throughout the course of this project. Her keen interest in our work,
constructive advice, and constant motivation have been instrumental in the successful
completion of our project.

We also extend our heartfelt thanks to our parents for their unwavering support and
encouragement. Additionally, we are grateful to our classmates for their timely help and
support, which significantly contributed to the completion of this project.

Lastly, we would like to thank everyone who directly and indirectly assisted us in completing
this project.

 Danesh Faisal (Class 12 B)

 Zaki Sajid (Class 12 B)

 Salman Riyas (Class 12 A)

 Team Name: V3NOM

 School: Doha Modern Indian School

 Subject: IP

4 V3NOM
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 V3NOM
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

6. Python Virtual Environment


 Virtualenv or venv: To manage project-specific dependencies and avoid conflicts

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

6 V3NOM
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

7 V3NOM
HARDWARE REQUIREMENTS

To ensure the railway reservation system runs efficiently and effectively, here are the minimum and
recommended hardware requirements:

Minimum Hardware Requirements


 Processor: Intel Core i3 (or equivalent AMD processor)
 Memory (RAM): 4 GB
 Storage: 10 GB free disk space
 Network: Basic internet connection for downloading dependencies and database connectivity
 Display: 1280 x 720 resolution monitor
 Peripherals: Standard keyboard and mouse

Recommended Hardware Requirements


 Processor: Intel Core i7 or AMD Ryzen 7 (or higher)
 Memory (RAM): 16 GB or more
 Storage: 256 GB SSD or more for fast data access and storage
 Network: High-speed internet connection (100 Mbps or higher)
 Display: 1920 x 1080 resolution monitor or higher
 Peripherals: Standard keyboard and mouse; optional multi-monitor setup for enhanced
productivity

8 V3NOM
INTRODUCTION

Railway Reservation System: Program Overview


This Python program is designed to simulate a comprehensive railway reservation system,
providing a user-friendly interface for booking train tickets, managing reservations, and
performing various administrative operations. The system offers functionalities for booking
tickets, viewing train schedules, canceling reservations, and analyzing data related to train
travel, such as fares and distances.

Key Features and Functionalities


The program encompasses several critical features aimed at streamlining the process of train
travel management:
1. User Interface:
 A menu-driven interface that allows users to navigate through different options and
perform various operations seamlessly.
2. Ticket Booking Confirmation:
 After a successful booking, the system generates and displays a Passenger Name
Record (PNR) number along with a confirmation message.
3. Train Listings:
 Users can view available trains between specified stations or access a complete list
of all trains.
4. Reservation Details:
 Users can check the details of their booked tickets by entering the PNR number.
5. Ticket Cancellation:
 The system confirms the cancellation of a ticket after validating user-provided
details.
6. Data Analytics:

9 V3NOM
 The program can generate various plots and visualizations related to train fares,
distances, and passenger data using the Matplotlib library.

Input and Output


Inputs:
 Admin Password: Required to access the system and perform administrative
tasks.
 User Details: Passenger details such as name, age, gender, phone number, and
email.
 Journey Details: Information such as source station, destination station, and date
of journey.
 Operation Choices: Users can choose from options like ticket booking, viewing
trains, ticket cancellation, and analytics.

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.

Program Logic and Workflow


The program follows a structured workflow to achieve its functionalities:
1. Admin Authentication:
 The program starts by prompting the user to enter an admin password to access the
system.
2. Database Connection:

10 V3NOM
 Upon successful authentication, the program establishes a connection to a MySQL
database named "Class12Project" and ensures necessary tables are created.
3. Dashboard Display:
 A dashboard with options for admin access, information about the creators, and an
exit option is displayed.
4. Main Menu:

 If admin access is selected, the main menu presents options for ticket booking,
viewing train schedules, checking booked tickets, canceling tickets, and performing
analytics.
5. Function Execution:
 Based on the user's choice, the program executes the corresponding function:
 Ticket Booking: Prompts for passenger and journey details, generates a
PNR number, and books the ticket in the database.
 Viewing Trains: Displays available trains between user-specified source and
destination stations.
 Train List: Retrieves and displays all available trains from the database.
 Booked Tickets: Shows ticket details when the user provides a PNR number.
 Canceling Tickets: Cancels the ticket after verifying the PNR number, name,
and phone number.
 Analytics: Generates and displays various plots and visualizations related to
train data.
6. Continuous Operation:
 The program continues to run, allowing the user to perform multiple operations until
they choose to exit.

Data Handling and Transformation


Throughout the program, several data transformations and logical flows occur to ensure
smooth operation:
 PNR Generation: Randomly generates unique PNR numbers for each booking.
 Input Validation: Validates user inputs, such as ensuring correct phone number
formats.
 Database Operations: Executes database operations like insertions, deletions, and
queries to manage reservations and retrieve necessary data.

11 V3NOM
By following this structured approach, the railway reservation system effectively manages
various aspects of train travel, providing a robust and user-friendly solution for booking and
managing train tickets.

TABLE STRUCTURE

 Project On “RAILWAY RESERVATION SYSTEM”

 DBMS: MySQL

 Host: localhost

 User: root

 Password: root

 DataBase: class12project

 Table Structure: >>>

 Table Display: >>>

12 V3NOM
13 V3NOM
14 V3NOM
PYTHON CODE

#Class XII Science Project


# Made By TEAM V3NOM XII-B 2024-25

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
15 V3NOM
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)

qry03="CREATE TABLE IF NOT EXISTS Passenger_Details (Pnr_Number int(10)


primary key,Psn_Name varchar(25),Psn_Ph_no VARCHAR(10),Psn_age int(10),Psn_gender
char(1),Train_from varchar(20),Train_to varchar(20),Scheduled_Date DATE,Email_ID
varchar(30),Fare int(12))"
crs.execute(qry03)

qry21 = "INSERT INTO Passenger_Details VALUES


(1021959091,'AHMED',24681357,25,'M','AJMER','DELHI','2024-03-
09','ahmed_123@gmail.com',50.00) ON DUPLICATE KEY UPDATE
Pnr_Number=1021959091"
qry22 = "INSERT INTO Passenger_Details VALUES
(1021959311,'FATIMA',78543219,21,'M','AJMER','AJMER','2024-03-
29','fatima.ahmed@yahoo.com',75.00) ON DUPLICATE KEY UPDATE
Pnr_Number=1021959311"
qry23 = "INSERT INTO Passenger_Details VALUES
(1021959332,'HASSAN',90123456,20,'F','AGRA','MATHURA','2024-05-
19','hassan123@hotmail.com',112.3) ON DUPLICATE KEY UPDATE
Pnr_Number=1021959332"
qry24 = "INSERT INTO Passenger_Details VALUES
(1021959301,'AISHA',35795128,26,'M','SHIMLA','BANGLORE','2024-05-
05','aisha_786@outlook.com',65.00) ON DUPLICATE KEY UPDATE
Pnr_Number=1021959301"
qry25 = "INSERT INTO Passenger_Details VALUES
(1021951231,'YUSUF',46802473,24,'M','CHENNAI','KANYKUMARI','2024-03-
25','yusuf123@live.com',32.00) ON DUPLICATE KEY UPDATE Pnr_Number=1021951231"
qry26 = "INSERT INTO Passenger_Details VALUES
(1021959441,'ZARA',15935746,21,'M','HALDIA','DELHI','2024-05-
09','zaraali@gmail.com',75.00) ON DUPLICATE KEY UPDATE Pnr_Number=1021959441"
qry27 = "INSERT INTO Passenger_Details VALUES
(1021952331,'ZAINAB',80246713,22,'M','LUCKNOW','VARANASI','2024-06-
16 V3NOM
23','zainab.khan@icloud.com',95.00) ON DUPLICATE KEY UPDATE
Pnr_Number=1021952331"
crs.execute(qry21)
crs.execute(qry22)
crs.execute(qry23)
crs.execute(qry24)
crs.execute(qry25)
crs.execute(qry26)
crs.execute(qry27)
#v3nom 2024-2025
qry04="USE Class12Project"
crs.execute(qry04)
qryo2="CREATE TABLE IF NOT EXISTS avail_Train(Srno int(10),Train_No int(15)
primary key,Train_Name varchar(250),Train_from varchar(200),Train_to varchar(300), fare
DECIMAL(10, 2))"
crs.execute(qryo2)

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"

17 V3NOM
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"

18 V3NOM
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)
19 V3NOM
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
20 V3NOM
print("""
***************************** DASHBOARD
********************************

+--------------------------------+
| 1. ADMIN ACCESS |
+--------------------------------+
+--------------------------------+
| 2. CREATORS |
+--------------------------------+
+--------------------------------+
| 3. EXIT |
+--------------------------------+ """)
break
e=input(" || **SELECT** || :- ")
#v3nom 2024-2025

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:
21 V3NOM
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('''

DEVELOPED BY V3NOM GANG XII-B 2024-25


''')

else:
print(" ")
print("~!~!~!~WRONG CHOICE PLEASE ENTER A VALID VALUE~!
~!~!~")
return("")

def ticket_booking():

import mysql.connector
import re
#v3nom 2024-2025
22 V3NOM
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.: ')

# Validate phone number


while True:
Psn_Ph = input('Enter your Phone No.: ')
if re.match(r'^\d{8}$', Psn_Ph):
break
else:
print("Invalid phone number. Please enter an 8-digit number.")
#v3nom 2024-2025
Psn_Ph_no = str(Psn_Ph)
Psn_age = int(input('Enter your Age: '))
print()
print(' M=MALE', '\t', 'F=FEMALE', '\t', 'N=NOT TO MENTION')
while True:
Psn_gender = input('Enter your Gender M/F: ')
if Psn_gender == ("M") or Psn_gender == ("F"):
break
elif Psn_gender == ("m") or Psn_gender == ("f"):
break
else:
print(" !~!~!~~ M\F only ~~!~!~!~")
Gender = Psn_gender.upper()
print()
print('Journey Details__')
Train_from = input(' From Station: ')
Train_to = input(' Destination: ')
Scheduled_Date = input('Enter Date of Journey (YYYY-MM-DD): ')
#v3nom 2024-2025
Pnr_Number = "10" + str(Psn_age) + str(rd.randint(100000, 999999))
Email_ID = input("Enter the Email ID: ")
Fare = rd.randint(400, 1200)
s1 = "INSERT INTO Passenger_Details VALUES(%s,%s,%s,%s,%s,%s,%s,%s,
%s,%s)"
data = (Pnr_Number, Psn_Name, Psn_Ph_no, Psn_age, Psn_gender,
Train_from, Train_to, Scheduled_Date, Email_ID, Fare)
crs.execute(s1, (data),)
23 V3NOM
print()
print(' ***TICKET BOOKED SUCCESSFULLY***')
print("\t", "Your Pnr Number is: ", Pnr_Number)
return ""
#v3nom 2024-2025

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")

Sr_train = input("Enter the Source Station: ")


De_train = input("Enter the Destination Station: ")
qry = 'SELECT * FROM avail_train WHERE TRAIN_NO = 12009'
crs.execute(qry)
data = crs.fetchall()
#v3nom 2024-2025
if not data:
print('~!~!~!~!~~NO DATA FOUND~~!~!~!~!~')
return pd.DataFrame()
else:
# Get the column names from the cursor description
columns = [desc[0] for desc in crs.description]

24 V3NOM
# Create a DataFrame from the data
df = pd.DataFrame(data, columns=columns)
print("")
print("")
print(df)
mydb.commit()
crs.close()
return ""

#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:

columns = [desc[0] for desc in crs.description]

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.:"))

25 V3NOM
#qry='DELETE FROM passenger_details WHERE Pnr_Number=(%s) or
Psn_Name=(%s) or Psn_Ph_no=(%s)'

s=input("ARE YOU SURE YOU WANT TO CANCEL THE TICKET (YES/NO):


")
a=[]
for i in s:
a.append(i)
#v3nom 2024-2025
if len(s)==3:
crs.execute('DELETE FROM passenger_details WHERE Pnr_Number=(%s)
or Psn_Name=(%s) or Psn_Ph_no=(%s)',(Self_Pnr,Self_Name,Self_Phno,))

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())

26 V3NOM
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)

plt.plot(x,y, marker="X",ls="dashed",linewidth=4, color="m")


plt.savefig("AC Fare For Trains.png")
plt.show()
return("")
#v3nom 2024-2025
def barh_plot():
print("Horizontal Bar Plot")

27 V3NOM
x=["Goa Express","JammuTavi Superfast","Punjab Mail
Express","Dakshin Express","Delhi-Mumbai Shatabdi"]
y=[1500,4500,2600,7600,9000]
plt.title("Sleeper Fare Of Trains",fontsize=14,color="b")
plt.xlabel("Trains",fontsize=14,color="c")
plt.ylabel("Sleeper Fare",fontsize=14,color="c")
plt.barh(x,y, color="y", edgecolor="pink")
plt.savefig("Sleeper Fare Of Trains.png")
plt.show()
return("")
#v3nom 2024-2025
def line1_plot():
print("Line Plot")
x=["Goa Express","JammuTavi Superfast","Punjab Mail
Express","Dakshin Express","Delhi-Mumbai Shatabdi"]
y=[500,1200,650,750,1350]
plt.title("Average Distance Covered By Train",fontsize=14,color="c")
plt.xlabel("Trains",fontsize=14,color="c")
plt.ylabel("(Distance in Kms)",fontsize=14,color="r")
plt.plot(x,y, marker="o", label="Avg Distance")
plt.xticks(rotation=17)
plt.legend()
plt.savefig("Avearage Distance By Trains.png")
plt.show()
return("")
#v3nom 2024-2025

if e=="1" :
print(railsmenu())
#v3nom 2024-2025
elif e=="2":
print(" ")
print( '''

________ ________ _______ ________ _________ ________ ________ ________


|\ ____\|\ __ \|\ ___ \ |\ __ \|\___ ___\\ __ \|\ __ \|\ ____\
\ \ \___|\ \ \|\ \ \ __/|\ \ \|\ \|___ \ \_\ \ \|\ \ \ \|\ \ \ \___|_
\ \ \ \ \ _ _\ \ \_|/_\ \ __ \ \ \ \ \ \ \\\ \ \ _ _\ \_____ \
\ \ \____\ \ \\ \\ \ \_|\ \ \ \ \ \ \ \ \ \ \ \\\ \ \ \\ \\|____|\ \
\ \_______\ \__\\ _\\ \_______\ \__\ \__\ \ \__\ \ \_______\ \__\\ _\ ____\_\ \
\|_______|\|__|\|__|\|_______|\|__|\|__| \|__| \|_______|\|__|\|__|\_________\

28 V3NOM
=======================================================================
==========================================================
1. DANESH FAISAL
=======================================================================
==========================================================

Role: Coding and Output

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.

=======================================================================
==========================================================
2. 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"
29 V3NOM
" || THANK YOU ||\n"
"
##======================================================##\n"
"\n")
print('''

DEVELOPED BY V3NOM GANG XII-B 2024-25


''')
else:
print(" ")
print("~!~!~!~PLEASE CHOOSE OPTION FROM 1-3~!~!~!~")
mydb.close()
except():
pass
else:
print("Password is incorrect,\nPlease enter the correct password.")
a2=str(input("Enter any number to again apply for password or press any alphabet to
exit:"))
print()
if a2.isalpha():
print("Thanks for using our service.")
break

INPUT/OUTPUT SCREEN

30 V3NOM
31 V3NOM
32 V3NOM
33 V3NOM
34 V3NOM
35 V3NOM
36 V3NOM
37 V3NOM
38 V3NOM
39 V3NOM
40 V3NOM
41 V3NOM
42 V3NOM
BIBLIOGRAPHY

1. Sumita Arora (Python)

2. www.python.com

3. www.mysql.com

4. chat.openai.com

43 V3NOM

You might also like