CS Project Report
CS Project Report
Introduction to python 2
Hardware and software requirements 5
Introduction to project 6
Source code 8
Explanation of code 12
Sample outputs 15
Some more examples for booking by user 26
Future scope 31
Bibliography 31
1
INTRODUCTION TO PYTHON
Python is a popular, versatile programming language known for its simplicity
and readability. Created by Guido van Rossum and first released in 1991,
Python has evolved to become one of the most widely used programming
languages in the world. Here's an overview highlighting key aspects of Python:
2. Interpreted Language:
3. Dynamically Typed:
Python comes with a comprehensive standard library that provides tools for a
wide range of tasks, from web development to data manipulation. This reduces
the need for external libraries for many common operations.
2
5. Cross-Platform:
1. Web Development:
Python is commonly used for writing scripts to automate repetitive tasks, from
file organization to web scraping.
3
4. Game Development:
Pros:
Cons:
- Slower execution speed compared to compiled languages like C++ and Java
- High memory consumption, which may not be ideal for applications with tight
performance constraints
4
Conclusion:
• RAM: 16GB
Software:
5
INTRODUCTION TO THE PROJECT
Project title: Autorickshaw ride booking platform using Python and SQL
integration.
The program uses Python as front end programming language and MySQL
as backend for storing driver’s data and managing availability of riders for ride
bookings. Riders can book a ride upto 25kms inside Bengaluru.
Script Flow:
• Customer Interaction:
o Based on the input, the script calculates the fare and prompts for
confirmation.
• Driver Interaction:
6
SQL Table Structure:
7
Source code
import mysql.connector as m
con=m.connect(host='localhost',user='root',password='0000',database='dwadasha')
if con.is_connected():
print("Connection successful.")
else:
print("Connection unsuccessful")
mycur=con.cursor()
if who==1:
#BOOKING PROCESS
print(blr)
print(blr)
if dist in range(2):
8
print("Your fare will be 100 rupees.")
elif dist>=25:
if dist in range(25):
if conf==1:
v1=(blr[iniloc],)
mycur.execute(q1,v1)
driverdet=mycur.fetchall()
if driverdet:
mycur.execute(q2, v2)
con.commit()
else:
elif conf==2:
9
print("\nThank you for visiting us! Hope to see you again")
elif who==2:
avbl={1:"AVAILABLE",2:"NOT AVAILABLE"}
if ch==2:
print(blr)
print(avbl)
v3=(drid,name,vehno,phone,blr[loc],avbl[status])
mycur.execute(q3,v3)
con.commit()
elif ch==1:
print(avbl)
10
status=int(input("Enter your choice as numerical value="))
print(blr)
v4=(blr[loc],avbl[status],drid)
mycur.execute(q4,v4)
con.commit()
con.close()
11
EXPLANATION OF THE SOURCE CODE
The print statement gets printed based on whether the connection established between
Python and MySQL is successful or not.
• Area Selection:
o Up to 2 km: ₹50
o 2 to 6 km: ₹100
o 6 to 10 km: ₹130
o 10 to 15 km: ₹160
12
o 15 to 25 km: ₹250
The following statements get executed only when distance entered is less than
or equal 25kms and an if statement is used to satisfy the same.
• The customer is asked whether to confirm the booking and proceed for
payment or cancel the booking.
• If the customer confirms the booking, the script queries the database to
find a driver who is available and location is same as initial location of
user. The variable blr[iniloc] stores the initial location of the user.
• The cursor is asked to fetch all the drivers’/driver’s data satisfying the
above condition. This data is stored in variable ‘driverdet’. The data is a
list of tuples. Each tuple stores driver details in (name,vehicle number,
phone number) format. However, the very first element of the list or the
first tuple is selected and respective driver is assigned to the customer.
• If there are no drivers satisfying given condition a print statement is
printed saying there are no drivers available and the program ends
• driverdet[0] stores the entire first tuple in the list. driverdet[0][0] stores
driver’s name, driverdet[0][1] stores driver’s vehicle number and
driverdet[0][2] stores driver’s phone number.
• Driver details (name, vehicle number, phone number) are shown to the
customer.
• The driver's status and current location are updated to "NOT
AVAILABLE" and the destination location of user, respectively in the
SQL table ‘rikshaw’. The variable blr[finloc] stores final location of the
user
• If the customer chooses to cancel the booking, the program ends.
Driver Operations:
13
Registering as a Driver:
• New drivers can input their ID, name, vehicle number, phone number,
current location, and status.
• This data is inserted into the rikshaw table in the database.
Updating Availability:
Existing drivers can update their current location and availability status after
completing a ride by entering their driver id. This is done by displaying a
dictionary and driver selects his choice by entering a numerical value.
Corresponding changes are done in the SQL table.
14
Sample outputs
This is the table before all the sample outputs are generated.
Example 1:
1.First, mysql.connector connects SQL with python and a print statement saying
that the connection is successful is printed
2.Then a set of print statements are printed and a menu is given to the user to
select the choice whether the user is a customer or a rikshaw driver. The user
enters his choice as a numerical value.
3.Firstly let’s look at the path of the program when ‘1’ is given as input or a
customer is the user:
15
Here the customer chooses his current location and the final location he wants
to go from the given menu by giving a numerical value. Here the menu is
created as a dictionary type with input numbers from the user as keys and the
four major parts of Bengaluru as values.
In this case the customer’s initial location is in Bengaluru East and he wants to
go to Bengaluru South. So he enters a numerical value accordingly as given in
the menu.
The user then enters his exact location which however makes no change in the
table. Then the distance of the journey is entered by user itself and fare is
displayed accordingly. Then user chooses whether he wants to confirm booking
and pay or cancel the booking. If the user confirms the booking, driver details
are displayed if a driver is available in the user’s location
16
After a driver is assigned to the user, the driver details in the table are changed:
17
Example 2:
Here the user enters his choice for initial and final location as Bengakuru West
and Bengaluru North.
Here as the distance of the journey exceeds maximum distance for which the
service is available. So it shows that service is not available for that distance.
18
Example 3:
The user enters initial location as Bengaluru west and final location as
Bengaluru south.
The user enters his exact location and enters his distance of journey. Fare is also
displayed accordingly. Then the user confirms the booking. But due to
unavailability of drivers at that location at that time, it shows that no drivers are
available. This is due to all drivers in Bengaluru west are busy:
19
Example 4:
The user then chooses to update his availability for next ride. The driver enters
his ID and chooses to be available and changes his location to Bengaluru West.
20
Table before data gets updated:
21
Example 5:
The user confirms the booking and the same driver who updated her availability
and location a while ago gets assigned to the user as her location matches with
the user’s location.
22
Driver’s details are again changed in the table:
Example 6:
The user here wishes to go from HSR layout to malleshwaram. He enters the
details accordingly and a price of 250 rupees is displayed.
23
The user wants to cancel the booking and exits the platform. Accordingly, he
chooses his option.
Example 7:
The user chooses his choice as a driver and chooses to register himself as a new
driver.
The user then enters his details i.e his driver id which is given to him by the
platform, his name, vehicle number and phone number.
24
The driver then selects his current location and availability. All these
information entered by the driver will be inserted as a new row in the rikshaw
table:
25
Some more examples of bookings by users
1.
The user wishes to ride from Thyagarajanagar to JP nagar. So, he selects his
details accordingly. A driver is finally assigned to the user and further changes
are done in the table:
Before changes:
26
Even though 3 drivers are available at Bengaluru south, the first driver in the list
is assigned. The other two drivers’ details remain unchanged.
After changes:
27
2.
here the user chooses to travel from peenya to Jayanagar. He enters details
accordingly and confirms booking and a driver is assigned.
28
Now suppose many drivers update their availability and the table looks like this:
29
3.
30
Future scope
This program can be further developed to meet various needs and made user-
friendly.
Another section for admin controls can be added in the program along with that
of customer and driver.
In admin window, the number of rides, total fare collected, other expenses and
profit earned can be analysed. Number of rides assigned per driver can also be
analysed. All these can be done by creating another table for admin
Customer details can be taken and stored in another table and number of
customers using the platform can be analysed.
Distance of the journey can be made auto generated instead of asking the user to
enter it.
Bibliography
Computer science with Python by Sumita Arora for class XII.
https://www.python.org
https://en.wikipedia.org/wiki/Python_(programming_language)
31
32