0% found this document useful (0 votes)
5 views32 pages

CS Project Report

The document provides an overview of Python, highlighting its key features, popular use cases, and the pros and cons of the language. It also details a project for an autorickshaw ride booking platform that integrates Python with a MySQL database, outlining the hardware and software requirements, source code, and explanation of the code's functionality. Additionally, it includes sample outputs demonstrating the booking process and driver interactions.

Uploaded by

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

CS Project Report

The document provides an overview of Python, highlighting its key features, popular use cases, and the pros and cons of the language. It also details a project for an autorickshaw ride booking platform that integrates Python with a MySQL database, outlining the hardware and software requirements, source code, and explanation of the code's functionality. Additionally, it includes sample outputs demonstrating the booking process and driver interactions.

Uploaded by

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

Index

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:

Key Features of Python:

1. Simple and Readable Syntax:

Python's syntax is designed to be intuitive and closely resembles the English


language. This simplicity makes it an excellent choice for beginners and
encourages clear code, which is easy to read and maintain.

2. Interpreted Language:

Python is an interpreted language, which means that code is executed line-by-


line without the need for prior compilation. This makes it easier to test and
debug code.

3. Dynamically Typed:

Variables in Python do not need explicit declarations; their types are


determined at runtime. This flexibility makes coding faster but requires careful
programming to avoid type-related errors.

4. Extensive Standard Library:

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:

Python runs on various platforms, including Windows, macOS, and Linux,


making it a cross-platform language. Code written in Python can often be run on
different systems with minimal modification.

6. Community and Ecosystem:

Python has a vibrant and active community that contributes to a large


collection of libraries and frameworks. Examples include:

- Web Development: Django, Flask

- Data Science and Machine Learning: NumPy, Pandas, TensorFlow, scikit-


learn

- Web Scraping: Beautiful Soup, Scrapy

- Automation and Scripting: Selenium, PyAutoGUI

Popular Use Cases:

1. Web Development:

Python's frameworks like Django and Flask enable rapid development of


secure and scalable web applications.

2. Data Science and Machine Learning:

Python has gained immense popularity in data science due to powerful


libraries like Pandas, NumPy, Matplotlib, and machine learning libraries such as
TensorFlow, Keras, and scikit-learn.

3. Automation and Scripting:

Python is commonly used for writing scripts to automate repetitive tasks, from
file organization to web scraping.

3
4. Game Development:

Python can be used in game development through libraries such as Pygame.


Though not as fast as languages like C++, it is often used for prototyping and
simple game development.

5. Finance and Business Applications:

Python is utilized for financial data analysis, quantitative research, and


building financial models due to its robust analytical libraries.

Pros and Cons:

Pros:

- Easy to learn and use, especially for beginners

- Large and supportive community

- Extensive libraries and frameworks

- Strong integration with other languages (e.g., through Jython, IronPython)

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

- Weak mobile computing and mobile app development support

4
Conclusion:

Python's clear syntax, strong community, and versatility make it an ideal


language for both beginners and experienced developers. Its ability to adapt to
various types of projects, from simple scripts to complex web applications and
data science tasks, solidifies its reputation as a powerful, general-purpose
language.

Hardware and software used.


Hardware:

• CPU: Intel i5 (quad-core)

• RAM: 16GB

• Storage: 512GB SSD

Software:

• Python 3.10 installed.

• VS Code with Python and SQL extensions.

• MySQL Community Server installed and configured.

• mysql-connector-python and pandas installed via pip.

5
INTRODUCTION TO THE PROJECT
Project title: Autorickshaw ride booking platform using Python and SQL
integration.

It is a Python-based autorickshaw booking platform that integrates with a


MySQL database for storing and updating data related to drivers, locations, and
ride bookings.

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.

The script connects to a MySQL database using mysql.connector. The


connection is established with the specified host, user credentials, and database
name ‘dwadasha’. The driver details i.e driver’s ID, driver’s name, phone
number, vehicle number, driver’s location and driver’s availability are stored in
SQL table named ‘rikshaw’. The column driver id has primary key constraint.

Script Flow:

• Customer Interaction:

o The customer selects their area and enters journey details.

o Based on the input, the script calculates the fare and prompts for
confirmation.

o If confirmed, the script fetches available driver details from the


database, displays them, and updates the database with new driver
data.

• Driver Interaction:

o Drivers can either register or update their current status and


location.

o Upon updating, the script commits the changes to the database.

6
SQL Table Structure:

SQL table rikshaw:(Before execution of sample outputs)

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

print('Hello!\n Welcome to Autorikshaw booking platform!')

print("\nWho are you? \n1.Customer \n2.Rikshaw driver")

who=int(input("Enter your choice in numeric value="))

if who==1:

#BOOKING PROCESS

blr={1:'BENGALURU NORTH',2:'BENGALURU SOUTH',3:'BENGALURU EAST',4:'BENGALURU


WEST'}

print("\nSelect your current area:")

print(blr)

iniloc=int(input("Please select your choice in numberical type="))

print("\nSelect your destination area:")

print(blr)

finloc=int(input('Please select your choice in numerical type='))

input("\nEnter your current location:")

input("Enter your final location:")

dist=float(input('\nEnter the distance of your journey in kms='))

#SHOWING RIDE FARE

if dist in range(2):

print("Your fare will be 50 rupees.")

elif dist in range(2,6):

8
print("Your fare will be 100 rupees.")

elif dist in range(6,10):

print("Your fare will be 130 rupees")

elif dist in range(10,15):

print("Your fare will be 160 rupees")

elif dist in range(15,25):

print("Your fare will be 250")

elif dist>=25:

print("\nSorry, Rikshaw service is not available for this distance")

if dist in range(25):

print("\n1.Confirm my booking and proceed for payment. \n2.Cancel my booking")

conf=int(input("Enter your choice as a numerical value="))

if conf==1:

q1="select dname,vehno,phno from rikshaw where curloc=%s and curstatus


='available'"

v1=(blr[iniloc],)

mycur.execute(q1,v1)

driverdet=mycur.fetchall()

if driverdet:

print("Your booking is successful.")

print("\nYour driver details:\nDriver name:",driverdet[0][0],"\nVehicle


number:",driverdet[0][1],"\nPhone number=",driverdet[0][2])

print("\nTHANK YOU FOR USING OUR SERVICE.HOPE TO SEE YOU AGAIN!")

#UPDATING DRIVER'S DATA IN TABLE AFTER BOOKING BY THE USER

q2 = "UPDATE rikshaw SET curstatus = %s,curloc = %s WHERE vehno = %s"

v2 = ('NOT AVAILABLE',blr[finloc], driverdet[0][1])

mycur.execute(q2, v2)

con.commit()

else:

print("\nSorry, No drivers available at present. Try again later")

elif conf==2:

9
print("\nThank you for visiting us! Hope to see you again")

#UPDATING LOCATION AND AVAILABILITY BY THE DRIVER

elif who==2:

print("\n1.Update my availability for next ride \n2.Register my data as a


driver")

ch=int(input("Enter your choice="))

avbl={1:"AVAILABLE",2:"NOT AVAILABLE"}

blr={1:'BENGALURU NORTH',2:'BENGALURU SOUTH',3:'BENGALURU EAST',4:'BENGALURU


WEST'}

if ch==2:

#REGISTERING A NEW DRIVER'S DATA IN THE TABLE

drid=input("\nEnter your id:")

name=input("Enter your name:")

vehno=input("Enter your vehicle number")

phone=input("Enter your phone number:")

print("\nChoose your current location:")

print(blr)

loc=int(input("Enter your choice as numerical value="))

print("\nSelect your current status for a ride:")

print(avbl)

status=int(input("Enter your choice as numerical value="))

q3="insert into rikshaw values(%s,%s,%s,%s,%s,%s)"

v3=(drid,name,vehno,phone,blr[loc],avbl[status])

mycur.execute(q3,v3)

print("\nData updated. Thank you")

con.commit()

elif ch==1:

#UPDATING LOCATION AND AVAILABLITY AFTER A RIDE BY THE DRIVER

drid=input("\nenter your id:")

print("\nSelect your current status for a ride:")

print(avbl)

10
status=int(input("Enter your choice as numerical value="))

print("\nChoose your current location:")

print(blr)

loc=int(input("Enter your choice as numerical value="))

q4="update rikshaw set curloc=%s,curstatus=%s where d_id=%s"

v4=(blr[loc],avbl[status],drid)

mycur.execute(q4,v4)

print("\nData updated. Thank you")

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.

The script presents a menu for users to choose their role:

• Customer: Initiates the booking process.

• Rikshaw Driver: Provides options for updating their availability or


registering new driver details.

Booking Process (Customer):

• Area Selection:

o Customers select their initial and destination locations from a


predefined dictionary of areas in Bengaluru.
o The user is asked to choose a place among the four major parts of
Bengaluru, Bengaluru North, Bengaluru South, Bengaluru East and
Bengaluru West as a numerical value.
o The variable, ‘iniloc’ stores a numerical value representing initial
location and ‘finloc’ stores numerical value representing final
location.
o The dictionary ‘blr’ stores numerical values as keys and the
respective locations as values.
o The user is also asked to enter the exact initial and final location
for information purpose only and no change is done in the SQL
table.

• Fare Calculation: The fare is calculated based on the distance input by


the user in kilometres using if statements. The fare structure follows these
rules:

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

o Over 25 km: ‘Service unavailable’ is printed and the program ends

Confirmation and Driver Allocation:

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:

If the user is a rikshaw driver, he is asked to choose whether he wants to register


himself as a new driver or update his availability.

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:

Table before performing changes:

Table after performing changes:

17
Example 2:

Now suppose a second customer wishes to travel from Kengeri to Yelahanka


and enters distance as 25kms:

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.

No changes take place in the table in this case.

18
Example 3:

Now suppose another customer wishes to go from Magadi road to


Banashankari:

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:

Now suppose a driver wants to update his availability and location:

User enters his choice as a rikshaw driver

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:

Table after data is updated

21
Example 5:

Now suppose the same user in example 3 enters details again:

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:

Now supposes a user cancels his booking:

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:

Now suppose a new driver wants to register his details:

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.

Table before changes:

Table after changes:

28
Now suppose many drivers update their availability and the table looks like this:

29
3.

The next user wishes to travel from peenya to Yelahanka. Accordingly,


information is entered and a driver is assigned

Table after the changes:

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.

Ride fare can be changed depending on customer demands and market


condition.

Bibliography
Computer science with Python by Sumita Arora for class XII.

NCERT computer science for class 12

https://www.python.org

https://en.wikipedia.org/wiki/Python_(programming_language)

31
32

You might also like