7th Internship Report - Krushna

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 90

GUJARAT TECHNOLOGICAL UNIVERSITY

Chandkheda, Ahmedabad

Affiliated

SAL EDUCATION CAMPUS

SAL Engineering and Technical Institute

“Bus Seat Booking System”


A Report
Submitted By

Sureja Krushnakumar Ashokbhai 211260131513

Under Subject of

SUMMER INTERNSHIP (3170001)


Of
BACHELOR OF ENGINEERING
In
Computer Science Engineering

Under the guidance of


Prof. Tejas Patel

Academic Year
2023-24

Page 1 of 90
Sr. No Title Page No.
1 Completion Certificate by company 3
2 Completion Certificate by GTU PMMS portal 4
3 Completion Certificate by College 5
4 About the topic 6
5 Day 1 7
6 Day 2 16
7 Day 3 27
8 Day 4 39
9 Day 5 48
10 Day 6 59
11 Day 7 64
12 Day 8 68
13 Day 9 71
14 Day 10 74
15 Day 11 75
16 Day 12 78
17 Day 13 83
18 Day 14 86
19 Conclusion & Future Enhancements 89

Page 2 of 90
Page 3 of 90
ATTACH THE CERTIFICATE DOWNLOADED FROM PMMS

Page 4 of 90
SAL ENGINEERING AND TECHNICAL INSTITUTE
COMPUTER ENGINEERING/INFORMATION
TECHNOLOGY/COMPUTER SCIENCE
ENGINEERING
2023

CERTIFICATE

Date:

This is to certify that the “Bus Seat Booking System” has been carried out by Sureja Krushnakumar
Ashokbhai (211260131513) under my guidance in completion of Summer Internship in Computer
Engineering/Information Technology/ Computer Science & Technology Branch 7 th Semester of Gujarat
Technological University, Ahmedabad during the academic Year 2023-24.

Prof. Tejas Patel Prof. Madhuri Parekh


Internal Guide Head of Department
Computer Science Engineering CE & CSE Department
SETI SETI

Page 5 of 90
ABSTRACT

Bus Seat Booking System is a digital platform designed to make the seat reservation process in intercity
buses easy and convenient. At a time when online services have become an integral part of daily life, the
system offers passengers a user-friendly platform to search, select and book their preferred seats on various
bus routes effortlessly. The system aims to eliminate the problems associated with conventional ticketing
methods, such as long queues, the limited information availability and manual processes Providing an online
platform, passengers can get real-time information on bus schedules, seat availability and fares. This allows
users to make informed decisions and select the most appropriate options based on their preferences.

Page 6 of 90
DAY1: Introduction to python, Python Installation and CS
code Installation Introduction to Python

What is Python?

Python is a high-quality, versatile, and interpretable programming language known for its simplicity
and readability. It was developed by Guido van Rossum and first released in 1991. Python's design
philosophy emphasizes code readability and clean vocabulary, making it an ideal choice for begin-
ners and advanced users they are all skilled.

It is used for:

 Web Development

 Data Analysis and Visualization

 Machine Learning and Artificial Intelligence

 Scientific Computing

 Automation and Scripting

What can Python do?

 Python is used to build dynamic and interactive websites and web applications frameworks
like Django and Flask.

 Python is popular for data analysis and manipulation.

 Python is a leading language for machine learning and AI development.

 Python is used in scientific research for mathematical and scientific computations.

 Python's simplicity and readability make it an excellent choice for writing scripts and auto-
mating repetitive tasks.

Why Python?

 Python is available on multiple platforms, including Windows, macOS, and Linux.


This cross-platform compatibility allows developers to write code that works seam-
lessly across different operating systems.
 Python's clean and straightforward syntax resembles English, making it easy to read
and write.
Page 7 of 90
 Python comes with an extensive standard library that provides modules and functions
for various tasks, eliminating the need to build everything from scratch.

PYTHON INSTALLATION

Steps to install Python

To download Python on your system, you can use the following steps.
 Visit the official download page for Python on the Windows operating system.
 Locate a reliable version of Python 3, preferably version 3.10.11, which was used in testing
this tutorial.
 Choose the correct link for your device from the options provided: either Windows installer
(64-bit) or Windows installer (32-bit) and proceed to download the executable file.

Running the Executable Installer

 Once you have downloaded the installer, open the .exe file, such as python-3.11.04.exe, by
double-clicking it to launch the Python installer.
 Choose the option to Install the launcher for all users by checking the corresponding checkbox,
so that all users of the computer can access the Python launcher application.
 Enable users to run Python from the command line by checking the Add python.exe to PATH
checkbox.

Page 8 of 90
Setup Progress

After Clicking the Install Now Button the setup will start installing Python on your Windows sys -
tem. You will see a window like this.

Page 9 of 90
Final Installer Window

After completing the setup. Python will be installed on your Windows system. You will see a suc -
cessful message.

Verify the Installation

Close the window after successful installation. You can check if the installation of Python was
successful by using either the command line or the Integrated Development Environment (IDLE),
which you may have installed.
To access the command line, click on the Start menu and type “cmd” in the search bar. Then click
on Command Prompt.

We will utilize the Visual Studio code editor to execute Python programs and create Python
projects. There are specific actions to take in order to install the VS code:

VS CODE INSTALLATION
Page 10 of 90
Visual Studio Code is the most popular code editor and the IDEs provided by Microsoft for writ -
ing different programs and languages. It allows the users to develop new code bases for their ap -
plications and allow them to successfully optimize them and debug them properly. It is a very
user-friendly code editor and it is supported on all the different types of operating systems like
Windows, macOS, and Linux. It has the support for all the languages like C, C++, Java, Python,
JavaScript, React, Node JS, etc. It is the most popular code editor in India also. It allows users
with different types of in-app installed extensions for the different types of their supported lan -
guages. It allows the programmers to write the code with ease with the help of these extensions.
Also, Visual Studio Code has a great vibrant software UI with amazing night mode features. It
suggests auto-complete code to the users which suggests the users complete their code with full
ease.

Installing Visual Studio Code on Windows:

Follow the below steps to install Visual Studio Code on Windows:

Step 1: Visit the official website of the Visual Studio Code using any web browser like Google
Chrome, Microsoft Edge, etc.

Step 2: Press the “Download for Windows” button on the website to start the download of the
Visual Studio Code Application.

Step 3: When the download finishes, then the Visual Studio Code icon appears in the
downloads folder.

Page 11 of 90
Step 4: Click on the installer icon to start the installation process of the Visual Studio Code.

Step 5: After the Installer opens, it will ask you for accepting the terms and conditions of the
Visual Studio Code. Click on I accept the agreement and then click the Next button.

Step 6: Choose the location data for running the Visual Studio Code. It will then ask you for
browsing the location. Then click on Next button.

Page 12 of 90
Step 7: Then it will ask for beginning the installing setup. Click on the Install button.

Step 8: After clicking on Install, it will take about 1 minute to install the Visual Studio Code on
your device.

Page 13 of 90
Step 9: After the Installation setup for Visual Studio Code is finished, it will show a window like
this below. Tick the “Launch Visual Studio Code” checkbox and then click Next.

Step 10: After the previous step, the Visual Studio Code window opens successfully. Now you
can create a new file in the Visual Studio Code window and choose a language of yours to begin
your programming journey!

Page 14 of 90
Writing first program in python:

Output:

Page 15 of 90
Day2: Datatypes, Operators, String functions, Type casting
DATA TYPES:

Built-in Data Types

In programming, data type is an important concept.

Variables can store data of different types, and different types can do different things

Python has the following data types built-in by default, in these categories:

Numeric Types: int, float, complex

Sequence Types: list, tuple, range

Mapping Type: dict

Set Types: set, frozenset

Boolean Type: bool

None Type: NoneType

Getting the Data Type

You can get the data type of any object by using the type() function:
Page 16 of 90
Setting the Data Type

In Python, the data type is set when you assign a value to a variable:

Page 17 of 90
Setting the Specific Data Type

If you want to specify the data type, you can use the following constructor functions:

OPERATORS:

Python Operators

Operators are used to perform operations on variables and values.

In the example below, we use the + operator to add together two values:

Page 18 of 90
Python divides the operators in the following groups:

 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Identity operators
 Membership operators
 Bitwise operators

Python Arithmetic Operators

Arithmetic operators are used with numeric values to perform common mathematical operations:

Program that shows all the Arithmetic Operations in one program

Page 19 of 90
Output:

Python Assignment Operators

Assignment operators are used to assign values to variables:

Program that shows the Assignments Operators

Page 20 of 90
Python Logical Operators

Logical operators are used to combine conditional statements:

Program that shows Logical operators

Python Membership Operators

Membership operators are used to test if a sequence is presented in an object:

Page 21 of 90
Program that contains membership Operators

STRING FUNCTIONS:

Python has a set of built-in methods that you can use on strings.

TYPE CASTING IN PYTHON

Type Casting is the method to convert the Python variable data type into a certain data type in or-
der to perform the required operation by users. In this article, we will see the various techniques
for typecasting.

There can be two types of Type Casting in Python:


Page 22 of 90
 Python Implicit Type Conversion
 Python Explicit Type Conversion

Explicit Type Conversion in Python


In this method, Python needs user involvement to convert the variable data type into the required
data type.

Examples of Type Casting in Python:

Mainly type casting can be done with these data type functions:

 Int():Python Int() function take float or string as an argument and returns int type object.
 float():Python float() function take int or string as an argument and return float type object.
 str():Python str() function takes float or int as an argument and returns string type object.

Implicit Type Conversion in Python

In this, method, Python converts the data type into another data type automatically. Users don’t
have to involve in this process.

Example:

Output:

Page 23 of 90
Some tasks provide by the Industry

TASK1: Take two input from user one as length and another as breadth and find the area and peri-
meter of rectangle

Output:

TASK2: Write a program that calculate the radius of the circle

Page 24 of 90
Output:

TASK3: Ask the user to enter their height in feet and display the result into cm

Output:

TASK4: Write a program to calculate the area and perimeter of regular hexagon ask user to enter
the sides

Page 25 of 90
Output:

TASK5: Ask user to enter input as litre and convert it into ml with output

Output:

Page 26 of 90
Day 3: Flow control statement, While loop
Flow Control Statement:
Control flow statements in Python are used to control the order in which the code is executed. They
allow you to make decisions and repeat actions based on conditions. Python provides several control
flow statements:

Types of Control Flow in Python:

In Python programming language, the type of control flow statements is as follows:


1. The if statement
2. The if-else statement
3. The nested-if statement
4. The if-elif-else ladder

Python if statement

The if statement is the simplest decision-making statement. It is used to decide whether a certain
statement or block of statements will be executed or not.
Syntax:
if condition:
# Statements to execute if
# condition is true

The condition can be any expression that evaluates to a Boolean value, such as True or False. If the
condition is true, the block of code inside the if statement will be executed. If the condition is false,
the block of code will be skipped.

Example of if statement:

Output:

Page 27 of 90
Python If-Else Statement

The if statement alone tells us that if a condition is true it will execute a block of statements and if
the condition is false it won’t. But if we want to do something else if the condition is false, we can
use the else statement with if statement to execute a block of code when the if condition is false.

Syntax:
if (condition):
# Executes this block if
# condition is true
else:
# Executes this block if
# condition is false

Example of if-else statement:

Output:

Nested-If Statement in Python

A nested if is an if statement that is the target of another if statement. Nested if statements mean
an if statement inside another if statement. Yes, Python allows us to nest if statements within if
statements. i.e., we can place an if statement inside another if statement.
Syntax:
if (condition1):

Page 28 of 90
# Executes when condition1 is true
if (condition2):
# Executes when condition2 is true
# if Block is end here
# if Block is end here

Example of Python Nested if statement

Output:

Python if-elif-else Ladder

Here, a user can decide among multiple options. The if statements are executed from the top
down. As soon as one of the conditions controlling the if is true, the statement associated with that
if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final
else statement will be executed.
Syntax:
if (condition):
statement
elif (condition):
Page 29 of 90
statement
.
.
else:
statement

Example of Python if-elif-else ladder

Output:

Python While Loop

Python While Loop is used to execute a block of statements repeatedly until a given condition is
satisfied. And when the condition becomes false, the line immediately after the loop in the
program is executed.

Syntax:
while expression:
statement(s)

Page 30 of 90
While loop falls under the category of indefinite iteration. Indefinite iteration means that the
number of times the loop is executed isn’t specified explicitly in advance.

Statements represent all the statements indented by the same number of character spaces after a
programming construct are considered to be part of a single block of code. Python uses indenta -
tion as its method of grouping statements. When a while loop is executed, expr is first evaluated in
a Boolean context and if it is true, the loop body is executed. Then the expr is checked again, if it
is still true then the body is executed again and this continues until the expression becomes false.

Example of While loop:

Output:

Page 31 of 90
Some tasks provide by the Industry

TASK1: Ask user to enter a integer number and check if its positive or negative with output

Output:

TASK2: Ask a user to enter name of a month and display weather it has 30 days or 31 days.

When we run this program, it will prompt you to enter the name of a month. After providing the
input, it will look up the number of days for that month using the dictionary days_in_month and
then display the result.

Page 32 of 90
For example, if you enter "March", the program's output might look like this:

If you enter "April", the output might look like this:

TASK3: Ask the user to enter their age if its below or equal to 13 the display they are child, if its
between 14 to 18 then display they are teenagers, if its between 19 to 30 then display they are
adults.

Output:
For example, if you enter an age of 10, the program's output might look like this:

If you enter an age of 16, the output might look like this:

Page 33 of 90
And if you enter an age of 25, the output might look like this:

TASK-4 Ask the user to enter a character and check if its consonant or not and display message if
its consonant or not.

Output:
When you run this program, it will prompt you to enter a character. After providing the input, it
will check whether the character is a lowercase alphabet and whether it's a consonant or not, then
display the corresponding message.

For example, if you enter the character "a", the program's output might look like this:

If you enter the character "b", the output might look like this:

And if you enter the character "7" (a non-alphabet character), the output might look like this:

Page 34 of 90
TASK5: Ask the user to enter three sides of triangle and check if its Equilateral triangle (all sides
equal), Isosceles (Two sides equal), Scalene (No side equal). Display message indicating its type.

Output:
For example, if you enter the sides 5, 5, and 5, the program's output might look like this:

If you enter the sides 3, 4, and 4, the output might look like this:

And if you enter the sides 7, 8, and 9, the output might look like this:

Page 35 of 90
TASK6: Ask user to enter a password (Keep password static). Keep asking for the password until
it is correct and the print a message that access granted. (while loop)

Output:

TASK7: Ask user to enter number greater the 0 and keep subtracting 1 from it until it becomes 0,
display result each time you subtract 1 from number.

Output:

Page 36 of 90
TASK8: Write a program that counts down from 10 to 1 and display each number during the loop.

Output:

TASK9: Write a program that generates random numbers between 1 to 10 until a number grater
then 8 is generated and display each generated number during the loop.

Output:

Page 37 of 90
TASK10: Ask user to enter numbers until he/she enters a negative number and display sum of all
number entered before that negative number.

Output:

Page 38 of 90
Day 4: for loop, range function, data structures-List, set
For loop in python

A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a
string).

This is less like the for keyword in other programming languages, and works more like an iterator
method as found in other object-orientated programming languages. With the for loop we can ex-
ecute a set of statements, once for each item in a list, tuple, set etc.

Syntax:

for Val in sequence:

# statement(s)

Flowchart of for loop

Page 39 of 90
Example of for loop

Output:

Range () Function in python

The Python range () function returns a sequence of numbers, in a given range. The most
common use of it is to iterate sequences on a sequence of numbers using Python loops.

Syntax: range (start, stop, step)

Parameter:
 start: [ optional] start value of the sequence
 stop: next value after the end value of the sequence
 step: [ optional] integer value, denoting the difference between any two numbers in the se-
quence

Return: Returns an object that represents a sequence of numbers

What is the use of the range function in Python

In simple terms, range () allows the user to generate a series of numbers within a given range. De -
pending on how many arguments the user is passing to the function, the user can decide where
that series of numbers will begin and end, as well as how big the difference will be between one
number and the next. Python range () function takes can be initialized in 3 ways.
 range (stop) takes one argument.
 range (start, stop) takes two arguments.
 range (start, stop, step) takes three arguments.

Example:

Page 40 of 90
Output:

Data Structure: List and Set

List in python
Python Lists are just like dynamically sized arrays, declared in other languages (vector in C++
and Array List in Java). In simple language, a list is a collection of things, enclosed in [ ] and
separated by commas.

Syntax:
List = ['value1','value2','value3']

Example:

Output:

Page 41 of 90
Set in python
A Set in Python programming is an unordered collection data type that is iterable, mutable and
has no duplicate elements.

Syntax:
This_set = {"value1", "value2", "value3", "value4"}
print(this_set)

Example:

Output:

Set items can be of any data type:

Output:

Some tasks provide by the industry

TASK1: Write a program that prints the numbers from 1 to 50 but skip odd numbers using a for
loop and range function.

Page 42 of 90
Output:

TASK2: Create a program that asks the user to enter a word and displays each character of the word
on a separate line using a for loop.

Output:

TASK3: Write a program that calculates the sum of all the numbers from 1 to 100 using a for loop.
Display the sum.

Output:

Page 43 of 90
TASK4: Create a program that prompts the user to enter a series of numbers. Calculate the average
of the entered numbers using a for loop. Display the average.

Output:

TASK5: Perform 5 built in operations on list.

Appending Elements: You can use the append () method to add an element to the end of the list.

Output:

Removing Elements: The remove () method allows you to remove a specific element from the
list.

Output:

Page 44 of 90
Copying Lists: You can create a copy of a list using either the copy() method or the list slicing
technique.

Output:

TASK6: Write a program that creates an empty list and prompts the user to enter five names. Add
each name to the list and display the final list.

Output:

TASK7: Create a program that generates a list of numbers from 1 to 10. Display the list of
numbers.

Output:

Page 45 of 90
TASK8: Write a program that prompts the user to enter a series of numbers. Store the numbers in a
list and display the list in reverse order.

Output:

TASK9: Write a program that prompts the user to enter a series of names. Add the names to a list
and display the list in alphabetical order.
Set: -

Output:

Page 46 of 90
TASK10: Write a program that creates an empty set and prompts the user to enter five numbers.
Add each number to the set and display the final set.

Output:

TASK11: Create a program that asks the user to enter a sentence. Split the sentence into words
and store the unique words in a set. Display the set of unique words.

Output:

Page 47 of 90
Day 5: Data structures, Tuple, Dictionary, Functions,
Recursion
Data structure – Tuple and Dictionary

Tuple in python
A tuple in Python is similar to a list. The difference between the two is that we cannot change the
elements of a tuple once it is assigned whereas we can change the elements of a list.

Creating a Tuple
A tuple is created by placing all the items (elements) inside parentheses (), separated by commas.
The parentheses are optional, however, it is a good practice to use them.

A tuple can have any number of items and they may be of different types (integer, float, list, string,
etc.).

Example:

Output:

Create a Python Tuple with One Element


In Python, creating a tuple with one element is a bit tricky. Having one element within parentheses
is not enough.
We can use the type () function to know which class a variable or a value belongs to.

Page 48 of 90
Output:

Dictionary in python
In Python, a dictionary is a collection that allows us to store data in key-value pairs.

Creating a Dictionary
We create dictionaries by placing key: value pairs inside curly brackets {}, separated by commas.

Example:

Output:

Some operations that can be performed with Dictionary:

Access Dictionary Items


We can access the value of a dictionary item by placing the key inside square brackets.

Page 49 of 90
Output:

Change Dictionary Items


Python dictionaries are mutable (changeable). We can change the value of a dictionary element by
referring to its key. For example,

Output:

Add Items to a Dictionary

We can add an item to the dictionary by assigning a value to a new key (that does not exist in the
dictionary). For example,

Page 50 of 90
Output:

Functions in Python

In Python, a function is a block of code that performs a specific task or set of tasks. Functions are
used to organize and modularize code, making it more readable, reusable, and easier to maintain.
They allow you to break down complex programs into smaller, manageable pieces.

Here's an overview of how functions work in Python:

Defining a Function: To define a function, you use the def keyword followed by the function
name, a pair of parentheses (), and a colon: The code block for the function is indented below the
def line.

Calling a Function: To use a function, you "call" it by using its name followed by parentheses.
You can pass values (arguments) inside the parentheses if the function expects any.

Parameters and Arguments: A function can take zero or more parameters (inputs), which are
defined within the parentheses of the function definition. When you call the function, you provide
the actual values (arguments) for these parameters.

Return Statement: Functions can have a return statement, which specifies the value that the
function should give back to the caller. If a function doesn't have a return statement, it returns
None by default.

Page 51 of 90
Default Arguments: You can provide default values for function parameters. If an argument isn't
provided when calling the function, the default value will be used.

Syntax:
def function_name(arguments):
# function body
Return

Example:

Output:

Recursion in Python
In Python, we know that a function can call other functions. It is even possible for the function to
call itself. These types of constructs are termed as recursive functions.

Illustration of recursion:

Page 52 of 90
Example:

Output:

In the above example, factorial () is a recursive function as it calls itself.

When we call this function with a positive integer, it will recursively call itself by decreasing the
number.

Each function multiplies the number with the factorial of the number below it until it is equal to
one. This recursive call can be explained in the following steps.

Some tasks provide by the industry

TASK1: Write a program that prompts the user to enter three characters. Create a tuple with the
entered numbers and display the tuple.

Page 53 of 90
Output:

TASK2: Create a program that generates a tuple of odd numbers from 1 to 20. Display the tuple of
odd numbers.

Output:

TASK3: Create a program that prompts the user to enter a series of names. Add the names to a
tuple and display the tuple in reverse order.

Output:

Page 54 of 90
TASK4: Write a program that prompts the user to enter two sentences. Split each sentence into
words and create tuples for each sentence. Find the common words between the two tuples and
display them.

Output:

TASK5: Create a program that asks the user to enter a sentence. Split the sentence into words and
create a dictionary where each word is a key and its length is the value.

Output:

Page 55 of 90
TASK6: Write a program that prompts the user to enter a series of words and their meanings.
Create a dictionary where each word is a key and its meaning is the value. Display the dictionary.

Output:

TASK7: Define a function that accepts 3 values and returns the minimum of 3 values.

Output:

Page 56 of 90
TASK8: Define a function that accepts a number and returns weather the number is odd or not.

Output:

TASK9: Define a function that return the factorial of a number.

Output:

Page 57 of 90
TASK10: Define a function that accepts a word and return its reverse.

Output:

Page 58 of 90
DAY6: Introduction and Installation of Django Create
project just as we created in session.
Introduction to Django

Django was design and developed by Lawrence journal world in 2003 and publicly released under
BSD license in July 2005. Currently, DSF (Django Software Foundation) maintains its development
and release cycle. Django was released on 21, July 2005. Its current stable version is 2.0.3 which
was released on 6 March, 2018.

Django is a high-level, open-source web framework written in Python that allows developers to
quickly and efficiently build web applications. It follows the Model-View-Controller (MVC) ar -
chitectural pattern, although in Django, it's often referred to as the Model-View-Template (MVT)
pattern. Django's primary goal is to simplify and expedite the process of building complex, data-
base-driven web applications by providing a set of tools and conventions.

Django gives you ready-made components to use such as:


1. It’s very easy to switch databases in the Django framework.
2. It has a built-in admin interface which makes it easy to work with it.
3. Django is a fully functional framework that requires nothing else.
4. It has thousands of additional packages available.
5. It is very scalable.

Features of Django:

 The versatility of Django: Django can build almost any type of website. It can also work with
any client-side framework and can deliver content in any format such as HTML, JSON, XML,
etc. Some sites which can be built using Django are wikis, social networks, new sites etc.

 Security: Since the Django framework is made for making web development easy, it has been
engineered in such a way that it automatically do the right things to protect the website. For
example, In the Django framework instead of putting a password in cookies, the hashed pass -
word is stored in it so that it can’t be fetched easily by hackers.

 Scalability: Django web nodes have no stored state, they scale horizontally – just fire up more
of them when you need them. Being able to do this is the essence of good scalability. Ins -
tagram and Disqus are two Django based products that have millions of active users, this is
taken as an example of the scalability of Django.

 Portability: All the codes of the Django framework are written in Python, which runs on many
platforms. Which leads to run Django too in many platforms such as Linux, Windows and Mac
OS.

Page 59 of 90
Installation and Setup of Django

Django is a Python web framework, thus requiring Python to be installed on your machine. At the
time of writing, Python 3.8 is the latest version.

To install Python on your machine, go to https://www.python.org/downloads/. The website should


offer you a download button for the latest Python version. Download the executable installer and
run it. Check the boxes next to “Install launcher for all users (recommended)” then click “Install
Now”.

After installation, open the command prompt and check that the Python version matches the version
you installed by executing:

About pip
Pip is a package manager for Python and is included by default with the Python installer. It helps to
install and uninstall Python packages (such as Django!). For the rest of the installation, we’ll
use pip to install Python packages from the command line.

Setting up a virtual environment

It is best practice to provide a dedicated environment for each Django project you create. There are
many options to manage environments and packages within the Python ecosystem, some of which
are recommended in the Python documentation. Python itself comes with venv for managing envir-
onments which we will use for this guide.

To create a virtual environment for your project, open a new command prompt, navigate to the
folder where you want to create your project and then enter the following:

This will create a folder called ‘project-name’ if it does not already exist and set up the virtual
environment. To activate the environment, run:

The virtual environment will be activated and you’ll see “(project-name)” next to the command
prompt to designate that. Each time you start a new command prompt, you’ll need to activate the
environment again.

Installation of Django

Django can be installed easily using pip within your virtual environment.
Page 60 of 90
In the command prompt, ensure your virtual environment is active, and execute the following com-
mand:

After the installation has completed, you can verify your Django installation by executing Django-
admin --version in the command prompt.

Now we will create project in Django

Below are steps to create a Django project with application:

Step 1:
To create a new project, first we need to select the folder in which we have to create a project, for
that we use the command ‘cd’. After cd write the path where we have to create a project. For
example if we have to create project on desktop the we will write ‘cd Desktop/’.

Step 2:
Once we select the directory, after that to create a new project, we use command ‘Django-admin.

start project ‘project name’ and the folder will be created itself.

After the project is created select the folder in which the project is created and then select the
project.

Page 61 of 90
Now the project is created, to create an application in it we need to follow below steps:

Step 3:
To create a new application in our project, ‘python manage.py start app ‘app name’ command will
be used.

Once we fire this command, the app will be created.

Page 62 of 90
Now our app is created and it contains all the required files that is going to be needed in future
development of the project.

Basic understanding of all the files that are included in the Django development kit.

manage.py: This is a command-line utility that allows you to interact with your Django project.
You can use it to run development server, create database tables, perform migrations, and more.

settings.py: This file contains all the configuration settings for your Django project. It includes
database settings, installed apps, middleware, template settings, authentication settings, and more.

urls.py: This file defines the URL patterns for your application. It maps URLs to views, allowing
you to specify how different URLs should be handled.

wsgi.py: This file is used for deploying your Django application using the WSGI (Web Server
Gateway Interface) standard. It provides a way for web servers to communicate with your Django
application.

models.py: In this file, you define your data models using Django's Object-Relational Mapping
(ORM) system. Each model represents a database table and its fields.

views.py: Views are Python functions or classes that handle HTTP requests and return HTTP
responses. They determine what content is displayed to the user.

Page 63 of 90
DAY7: Create tables based on whatever project has been
allotted to you. Perform display queries on them.

Installing and setting up database


To setup the database for the project we have to install any database application for the project. So
we are going to use DB Browser for SQLite.

After Installing DB Browser, it will look like this:

Understanding the files that are included in our app that we have created.

When you create a new app using the startapp command, Django generates a set of files and
directories within the app's directory. Here's a detailed explanation of the typical files that come
under the "app" in a Django project:

__init__.py: This empty file tells Python that the directory should be considered a package and
allows you to import modules from within the app directory.

admin.py: This file is used to define the administration interface for your app's models. You can
use the admin.py file to register models with the Django admin site and customize how they are
displayed and edited in the admin interface.

Page 64 of 90
apps.py: This file contains the app configuration. You can use it to configure various aspects of
your app, such as its name, verbose name, and default behaviour.
models.py: This is where you define your app's data models using Django's Object-Relational
Mapping (ORM) system. Each model represents a database table, and the fields in the model class
define the columns of the table.
tests.py: Django encourages writing tests for your app to ensure its functionality remains
consistent as you make changes. This file is where you can define unit tests, integration tests, and
other tests related to your app.
views.py: This file contains the views for your app. Views are Python functions that handle
incoming requests, process data, and return appropriate responses. Views are responsible for
rendering templates, handling form submissions, and more.
urls.py: The URL configuration for your app resides in this file. You define the URLpatterns that
map to your app's views. These URL patterns determine how URLs are mapped to specific views
within your app.
migrations/: This directory holds database migration files. Migrations are used to manage changes
to your app's data models over time. Django's migration framework generates and applies database
schema changes as you modify your models.
static/: This directory is where you can store static files like CSS, JavaScript, and images that are
used by your app. These files are typically served directly by the web server, not processed by
Django.
templates/: This directory is used to store HTML template files for rendering dynamic content.
Django's template engine allows you to separate the presentation logic from the rest of your code.
apps.py: This file contains the configuration for your app, including its name and any custom
configuration options you might want to define.
These are the main files and directories that you'll find in a Django app. However, it's important to
note that you can also create additional files or directories as needed to organize your app's code
and resources in a way that makes sense for your project.

Now we will setup the Django server

Page 65 of 90
Creating tables according to the project

By clicking the add button we can create the database and create the table .So, by entering the
details of the user we can add the user and add the user.

Entering the details and adding the new user.

As we can see in the screenshot that the user has been added.

Our project name is app1 and now we will configure the app1.

Page 66 of 90
Here we have configured the project, now we will be configuring the admin python file.

To setup the Django administration we to write this code in admin.py file.

Page 67 of 90
DAY 8: Creating html pages along with navigation bar in
which we can show category and read that page in views file.

First Creating the Home Page of the project:


So, home page has three things:
1. User login
2. Driver login
3. Home

Codes:
Home Page:

Implementation:

Page 68 of 90
Login Page:
So, basically there are two login pages:
1. User login
2. Driver login

User Login:
So, the user has two things to enter in the login page.
1. Email
2. Password
Code:

Implementation:

Page 69 of 90
Driver Login:
So, the driver has two things to enter in the login page.
1. Name
2. Password

Code:

Implementation:

Page 70 of 90
DAY9: Completing remaining html pages
In the user section there are two activities that user can do:
1. Booking tickets
2. Tracking buses

Implementation:

Page 71 of 90
Booking Tickets:
In this section, the user can book tickets.

Code:

Implementation:

As we can see in the screenshot our bus name is Zvilo and there are 3 seats available in the bus. It
also shows the time of the bus.

Page 72 of 90
Tracking Buses:
In this division the user can track the bus.

Code:

Implementation:

As we can see in the upper screenshot there are names of locations that has been covered by the
bus.

Page 73 of 90
DAY10: Creating Driver section (html pages)

In the driver section, the driver has an activity to do:

Code:

Implementation:

In the upper screenshot we can see that driver have an option to select the location that is covered
by the bus.

This features of given because the can able to know the locations covered by the bus.

Page 74 of 90
DAY11: Backend of login, register and logout pages and
creating first user and their details
Creating a login and logout system in Python with Django involves implementing the backend logic
to handle user authentication and sessions. Below are the key details for implementing these
functionalities.

Registration Page:
To setup the registration page with backend firstly, we have to work in models.py file in app1.

Code:

In models.py we will define the details of the new users that user can enter during the process of
their registration.

To add this section in admin we have to define a code in admin.py python file.

Now, we to add this in the url.py page to mention path of the register page.

After completing writing the code in these files we have setup the client-server architecture to do
this we will use REQUEST and POST method.

Login pages

Page 75 of 90
To setup the Login page with backend firstly, In Login page we don’t have to work in model.py file
and admin.py file because at the time of creating the registration page it.
Now we will directly work in url.py file to mention path of the register page.

Now we will add write the code in client-server architecture.

Logout:

Addition users, and buses.


After creating the DJANGO administration and setting up the database and completed the
registration, login and logout sections we now add the user, drivers and buses.

Adding a new user

As we can see, we have entered all the details in the registration form, now we will click on the
submit button and the new user will be added.

Page 76 of 90
After submitting the details our user is added in the database.

Adding a new bus


Now we add a new bus in the database, to add a new bus we have to add the details of the bus and
driver details in the administration sections.

We have entered all the details of the bus.

Page 77 of 90
DAY12: Backend code of all the sections of the project
After understanding the logic behind the login, logout and registration, now we will see the
remaining logics and code of other sections of the project.

So, when we enter in the user section there are list of buses. So, in the DJANGO administration
there we can able to add a new bus. In backend we have to declare all the details the bus.

So let’s see the backend code which we have to declare in our project. This code we have write in
models.py file.

After declaring this code, in Django administration now we have can add a new bus with details
such as – bus name, source and destination, source time destination time and it also contains driver
name and its password and number of seats in the buses and also while booking the tickets it show
how many seats are remaining.

So, in the upper screenshot, there are all details which we have to fill out to add a new bus
including driver’s details.

Page 78 of 90
Driver login and logout
After creating bus details section in Django administration, the driver login and logout has been
created. To access this in web we have to use client-server technique, to implement this in code we
will use get and post method. This thing is to be declare in the view.py file.

Driver Login:

Driver Logout:

In driver section, the driver can select and submit the location which is covered by the driver. So, it
can help the user to locate the bus.

So, firstly we have to declare this in views.py file for getting the page.

Now we have to declare a section of code in models.py file.

Page 79 of 90
Also, we have to declare all the paths in urls.py file.

Bus seat section, firstly we have to declare this in models.py file.

This code shows that in Django administration while we are adding a new bus there are some
additional sections of details which we have to fill in the bus details. The details such as driver
name, phone no and password.

Now, we have to add seat section in views.py file to access this in web.

To declare the path for these we have set the path in urls.py file.

Page 80 of 90
Now in views.py file we have made different sections for getting the access of the pages of our
project.

Sections such as:


1. Booking tickets
2. Bus List
3. Navigation
4. Home page
5. Get bus routes
6. Seat details
7. Marked routes

Booking tickets:

Bus List:

Navigation:

Page 81 of 90
Home Page:

Get bus routes:

Seat Details:

Marked Routes:

Page 82 of 90
Page 83 of 90
DAY13: Addition some user and Buses (also includes driver
details)
Adding Users
We will add some users. To add users, we two methods:
1. Manually adding the user in Django administration
2. Automatically adding the user by registering the signup page

1. Manually adding the user in Django administration


First Users:

Second user:

2. Automatically adding the user by registering the signup page

Page 84 of 90
Second User:

Adding Bus (including driver’s details)


We will add some buses, this also includes details of the driver. To add buses, we have only single
method that is to manually add the buses in Django administration

Adding the buses in Django administration

First bus:

Page 85 of 90
Second bus:

Adding drivers:

Page 86 of 90
DAY 14: Walkthrough and testing the project
As we know that our project is Bus Seat Book System, so let’s take a walkthrough of our project.

Basic Introduction
The Bus Ticket Booking System is a comprehensive online platform designed to streamline and
enhance the process of reserving and purchasing bus tickets. In an increasingly digital world, the
AMTS serves as an efficient and convenient solution for passengers to access bus schedules, select
preferred routes, and choose seat preferences.

Walkthrough of project
So, let’s start with the home page. Our home page contains two sections User login and driver
login.

Now we will go in user section by logging into the user login.

In the user section we have mainly two activities which user can perform
1. Booking
Page 87 of 90
2. Tracking

We can book tickets and track the buses. In the lower screenshot we can see that we are
booking 3 tickets.

After booking the tickets we can also track the buses.

After clicking on tracking, we can easily see all the locations covered by buses. It also shows the
timing that on which time bus has covered that location.

So, basically there is a table which contains three sections LOCATION, SPOT AND TIMING.
Location shows all names of the location that bus will going to be covered in its journey. Second
section is SPOT which indicates that if bus had travelled that location or not if location is covered
then true else false.
In the user section, after clicking on seat details it shows the number of buses which have empty
seats to book.

Page 88 of 90
So, this were the user section. Now we will proceed to the driver section. When we login into
driver section it welcomes the driver.

The driver section has a feature in which a list of locations has been given with the checkbox, now
the driver can fill the checkbox and submit it. Now the location which is submitted by the driver is
updated to the user that the bus has covered the location which driver has submitted.

So basically, the driver can update the user that the bus has covered by location by clicking and
submitting the location.

At last, these are the activities that our project can perform.

Page 89 of 90
CONCLUSION

In the rapidly evolving landscape of transportation and digital services, the implementation of our
Bus Seat Booking System has been a significant milestone. This project, developed using Python
and Django, has successfully addressed the challenges associated with traditional bus seat
reservation processes, and it has introduced a new level of convenience and efficiency for both
passengers and bus operators. Throughout the development and deployment of this system, we have
achieved several notable milestones. The Bus Seat Booking System has simplified the seat
reservation process, allowing passengers to book and pay for their seats online, reducing long
queues and manual paperwork. Passengers can stay informed about their bookings and receive real-
time updates on bus departures and arrivals, contributing to a more organized and stress-free travel
experience.

Future Enhancements

As we look to the future, there are several areas where we can further enhance the Bus Seat Booking
System. Expanding the range of payment options to cater to a broader audience. Utilizing data
insights to refine scheduling, pricing, and route optimization. Developing a mobile app for even
greater accessibility and on-the-go bookings. Introducing promotional campaigns and loyalty
rewards to further engage passengers. Continuously strengthening security measures to protect user
data and privacy. In conclusion, our bus seat reservation system has not only modernized bus
parking but has also helped to enhance the overall travel experience. With a commitment to
continuous improvement and integration of emerging technologies, we are poised to deliver
seamless and user-friendly transportation management solutions in the coming years.

Page 90 of 90

You might also like