DPG Institute of Technology and
Management, Gurgaon, Haryana (122102)
A
Lab/Practical File
On
Python Programming
Lab (LC-CSE-215G)
Submitted
For
Bachelor of Technology
in
Computer Science and Engineering
SUBMITTED TO: SUBMITTED BY:
Neelam Dahiya Aashutosh Kumar Jha
(Assistant Professor) 24CS01
INDEX
[Link]. NAMEOF EXPERIMENT DATE SIGNATUR
E
1 Introduction to the Python
Programming Language 08/08/2025
2 Write a simple python program to
perform arithmetic operations 15/08/2025
3 a) Find the GCD of two no s. and
display the result on screen. 22/08/2025
b) Find area of a circle, rectangle
.
4 To calculate the power of any given
number 29/08/2025
5 Perform all conditionals Statements.
29/08/2025
6 Perform all Looping Statements &
break, continue statement. 05/09/2025
7 Creation of list with its operation
sum( ), avg( ), Max( ), Min( ), 12/09/2025
Sort( )
8 8.(a) Linear Search 19/09/2025
(b) Binary Search
10
11
EXPERIMENT NO – 1
Aim:
To study and understand the Python programming language,its
history, features, and [Link] learn the basic syntax and
structure of Python programs.
Objective:
To learn about the origin and development of the Python
programming language.
To understand why Python was created and how it got its name.
To study the key features that makes Python popular and widely used.
Outcome:
Students will be able to explain the history and evolution of Python.
Students will understand the reasons behind Python’s popularity
and naming.
Students will be familiar with Python’s major features and advantages..
Theory:
Python is a high-level, interpreted, and general-purpose programming
language known for its simplicity and readability. It was created by Guido
van Rossum in 1989 at the Centrum Wiskunde & Informatica(CWI)in
the Netherlands and was officially released in 1991
The name "Python" was inspired by the British comedy televisions how
"Monty Python’s Flying Circus", not by the snake. Guido wanted a short,
unique, and
Slightly mysterious name.
Python emphasizes code readability and allows programmers to express
concepts in fewer lines of code compared to other languages like C++ or
Java. It supports multiple programming paradigms such as procedural,
object-oriented, and
Functional programming.
The first official version, Python1.0, was released in
[Link] features such as exception handling, functions,
and core data types like str, list, and dict.
Key Features of Python:
1. Simple and Easy to Learn–Syntax is clear and readable.
2. Interpreted Language–No need for compilation ;code runs directly.
3. Cross-platform–Works on Windows , macOS, Linux, etc.
4. Extensive Standard Library–Provides built-in modules for various tasks.
5. Dynamically Typed–No need to declare variable types explicitly.
6. Open Source–Freely available for everyone.
7. Large Community Support–Millions of developers contribute
to its growth.
Applications of Python:
Web Development (Django, Flask)
Data Science & Machine Learning (NumPy, Pandas, Scikit-learn)
Automation &Scripting
Game Development (Pygame)
Internet of Things (IoT)
Desktop GUI Applications
Python’s simplicity, versatility, and strong community make it one of the
most popular programming languages in the world today .
Latest Version of Python & IDLE
Latest Stable Version:
Python3.13.5, released on June11, 2025,is the most recent stable version
available
Pre-release/Alpha Releases:
The upcoming Python3.14 is currently in alpha (e.g.,3.14.0a5), notyet
stable
IDLE (Integrated Development and Learning Environment):
Comes bundled with a standard Python installation.
Last updated in sync with Python 3.13.5.
A light weight GUIeditor + interpreter shell ideal for learning
and writing small scripts.
Python Data Types :
Python has different types of data to store and process information. These
are the most common built-in data types:
1. Numeric Types
o int–Integer numbers(e.g.,5,-12)
o float–Decimal numbers(e.g.,3.14,-0.5)
o complex–Complex numbers(e.g.,2+3j)
2. Text Type
o str–String of characters(e.g.,"Hello", 'Python')
3. Sequence Types
o list–Ordered ,mutable collection(e.g.,[1,2,3])
o tuple–Ordered, immutable collection(e.g.,(4,5,6))
o range–Sequence of numbers (e.g., range(5))
4. Mapping Type
o dict–Key-value pairs(e.g.,{"name":"John", "age":25})
5. Set Types
o set–Unordered, unique elements(e.g.,{1,2,3})
o frozen set– Immutable set
6. Boolean Type
o bool–True or False
7. Binary Types
o bytes–Immutable sequence of bytes
o byte array–Mutable sequence of bytes
o memory view–View object for byte data
Python Operators:
Operators are special symbols or keywords used to perform operations
variables and values.
1. Arithmetic Operators– For mathematical calculations:
O + (Addition)
o - (Subtraction)
o * ( Multiplication)
o / (Division)
o % (Modulus–remainder)
o ** (Exponentiation–power)
o //(Floor Division–integer result)
2. Comparison (Relational) Operators–Compare values and return
True or False:
o !=(Not equal to)
o >(Greater than)
o <(Less than)
o >=(Greater than or equal to)
o <=(Less than or equal to)
3. Logical Operators– Combine conditional statements:
o and
o or
o not
4. Assignment Operators–Assign values to variables:
o=,+=,-=, *=,/= ,%=,**= ,//=
5. Bitwise Operators–Work on bits:
&(AND)
o
| (OR)
o
^ (XOR)
o
~ (NOT)
o
<<(Left Shift)
o
>>(Right Shift)
o
in
o
notin
o
6. Identity Operators–Check memory location of objects:
o is
o isnot
IDEs Used for Python Programming
In this experiment, I used two different Integrated Development Environments (IDEs) for writing and
executing Python programs: Jupyter Notebook and Visual Studio Code.
1. Jupyter Notebook
o Jupyter Notebook is an open-source web-based interactive environment for writing and
running code.
o It is especially useful for data science, machine learning, and educational purposes.
o It allows the code to be written in cells, which can be executed independently.
o Supports adding text, equations, images, and visualizations alongside the code using
Markdown.
o It runs in the browser and uses an IPython kernel to execute Python code.
2. Visual Studio Code (VS Code)
o Visual Studio Code is a lightweight but powerful source code editor developed by
Microsoft.
o It supports multiple programming languages, including Python, through extensions.
o Features include syntax highlighting, IntelliSense (code suggestions), debugging tools,
and integrated Git control.
o It allows execution of Python scripts directly in its integrated terminal.
o Highly customizable with themes, extensions, and settings according to the user’s
preference
Conclusion:
Python is an easy and powerful programming language created by Guidovan
Rossum in 1991. It is simple to read and write, works on all major platforms,
and can be used for many purposes like web development, data science, and
automation. The latest version, Python 3.13.5, along with tools like IDLE,
makes it easy to write and run programs. Learning Python’s history, features,
and uses gives a strong base for becoming a good programmer.
EXPERIMENT NO – 2
Aim: Write a simple python program to perform arithmetic operations.
Objective:
To understand the basic syntax of Python programming.
To implement user input and output in Python.
To perform basic arithmetic operations (addition, subtraction, multiplication, division, modulus).
Outcome:
Students learned how to write a basic Python program.
Understood the use of input() function for taking user input.
Gained knowledge of different arithmetic operators in Python.
Input:
Output:
EXPERIMENT NO – 3
Aim:
a) Find the GCD of two no s. and display the result on screen.
b)Find area of a circle, rectangle.
Objective:
To understand how mathematical problems like GCD and area calculation can be solved using
Python.
To learn taking user input (integers and floating values) and displaying results.
To practice arithmetic operations and formula implementation in Python.
Outcome:
Students were able to compute the GCD of two numbers using Python.
Successfully calculated the area of a circle and a rectangle by applying formulas.
Understood the use of Python’s math module for functions and constants.
Input:
Output:
Input:
Output:
EXPERIMENT NO – 5
Aim: To calculate the power of any given number
Objective
To understand the concept of exponentiation in Python.
To implement a program that calculates the power of a given number using operators or built-in
functions.
To develop problem-solving skills by applying mathematical operations in Python.
Outcomes
Successfully calculated the power of any given number in Python.
Learned to use the exponentiation operator (**) and the built-in pow() function.
Gained practical knowledge of applying mathematical operations in Python programming.
Improved logical thinking and coding efficiency by solving mathematical problems
programmatically.
Input:
Output:
EXPERIMENT NO – 5
Aim: Perform all conditionals Statements.
Objective
To understand the concept of decision-making in Python programming.
To learn how to use conditional branching (if, if-else, if-elif-else) for solving problems.
To write programs that can take decisions based on conditions.
To develop logical thinking for handling multiple scenarios in a program.
Outcomes
Understood the syntax and working of conditional statements in Python.
Gained the ability to implement if, if-else, and if-elif-else constructs in programs.
Learned how to control the flow of execution using decision-making statements.
1. If Statement : Statement will be executed only if the condition will match otherwise it will
be terminated.
Input :
Output :
2. If Else Statement: Statement will be executed only if the condition will match otherwise
else part will be executed.
Input:
Output:
3. If Elif Else Statement : It provide much more branching condition, satisfied condition
will be executed otherwise else part will be executed.
Input:
Output:
4. Nested If Statement: Using Conditional Statement inside Conditional statement is known
as Nested If.
Input:
Output:
EXPERIMENT NO – 6
Aim: To perform all Looping Statements.
Objectives
To understand the concept of iteration in Python.
To learn the use of while loop for condition-based repetition.
To learn the use of for loop for sequence/range-based repetition.
To minimize code repetition and improve efficiency.
Outcomes
Students can implement while loops for conditional iteration.
Students can implement for loops for sequence-based iteration.
Students can write efficient programs requiring repeated execution.
Students gain the ability to apply loops in problem-solving tasks.
1. While Loops:
Input:
Output:
2. For Loops:
Input:
Output:
Break Statement:
Input:
Output:
Continue Statements:
Input:
Output:
EXPERIMENT NO – 7
Objective:
To understand and perform basic operations on lists in Python such as sum(), average(),
max(), min(), and sort().
To demonstrate how lists can be used to store multiple values and perform aggregate
computations easily.
To develop problem-solving skills using Python’s built-in list functions for data analysis.
Outcomes:
Successfully calculated the sum of all elements in a list.
Computed the average (mean) of the list elements.
Identified the maximum and minimum values in the list.
Applied the sort() function to arrange the list elements in ascending/descending order.
Gained practical knowledge of handling list operations for mathematical and logical
computations.
1. Sum( ):
Input:
Output:
2. Avg( ):
Input:
Output:
3. Max( ):
Input:
Output:
4. Min( ):
Input:
Output:
5. Sort( ):
Input:
Output:
EXPERIMENT NO – 8
Aim: To perform Linear & Binary Search.
Objective
To understand and implement Linear Search and Binary Search algorithms using Python.
To study how searching is performed on unsorted and sorted lists.
To analyze and compare the time complexity and efficiency of both algorithms.
Outcome
Successfully implemented both Linear Search and Binary Search in Python.
Understood that Linear Search works on both sorted and unsorted lists, but is less efficient with a
time complexity of O(n).
Understood that Binary Search works only on sorted lists and is much faster, with a time
complexity of O(log n).
Gained practical knowledge of when to apply Linear Search (small or unsorted data) and Binary
Search (large, sorted data).
1. Binary Search:
Input
Output
2. Binary Search
Input
Output