UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
DEPARTMENT OF SCIENCE AND HUMANITIES
24GEES207–PYTHON PROGRAMMING
LABORATORY (AY: 2025-2026)
Common to All Branches
(AI&DS/CSE/CSE(CS)/ECE/IT/R&A)
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
BONAFIDE CERTIFICATE
This is to certify that the record work entitle Python Programming Laboratory
(24GEES207) is the Bonafide record of practical work done by
Name :
Register No :
Dept. :
Batch :
in the IInd Semester of B.E/[Link].
during the academic year 2025-26.
Staff-in-charge Head of the Department
Submitted for the End Semester Practical Examination held on ------------------------
Internal Examiner External Examiner
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
TABLE OF CONTENTS
[Link]. Date Name of the Experiment Page. No. Sign.
1 Program to Find the Factorial Number
2 Generating Armstrong Numbers
3 Fibonacci Series
4 Check the Given String is Palindrome
5 Distance Between Two Points
6 Greatest Common Divisor
7 Matrix Operations
8 Sorting
9 Program to Find the Area of Shapes
10 Program to Check the Triangle is Right
Angle
11 File Operations
12 Time and Calendar
13 Pattern Generation
14 Generation of Prime Numbers
15 Remove Duplicate Elements
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
PROGRAM TO FIND THE FACTORIAL NUMBER
Ex. No.: 01
Date:
Aim:
Write a python program to find the factorial of the given number and verify the result.
Software Required:
Python IDLE Version 3
Program:
#Recursion function
#To find the factorial of a number
using #recursive function
def fact(n):
if n==0:
return 1
else:
return n*fact(n-1)
while(1): #Continuous Process
print("This program is to find Factorial of given number")
n=int(input("Enter number for fact"))
FactResult=fact(n)
print("Factorial result of",n,"is",FactResult)
1
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The python program to find the factorial of the given number is written and executed and its output
is verified theoretically and practically.
2
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
GENERATING ARMSTRONG NUMBERS
Ex. No.: 02
Date:
Aim:
Write a python program to generate Armstrong number and verify the result practically.
Software Required:
Python IDLE Version 3
Program:
print('Generating Armstrong Numbers upto four Digits')
x=0
for x in range(Number):
Temp=x
Sum=0
Digit1=int(Temp%10)
Digit4=int(Temp/1000)
Digit3=int((Temp-(Digit4*1000))/100)
Digit2=int((Temp-(Digit1+Digit4*1000+Digit3*100))/10)
if x<999:
Sum=Digit4**3+Digit3**3+Digit2**3+Digit1**3
if x>999 and x<9999:
Sum=Digit4**4+Digit3**4+Digit2**4+Digit1**4
# print('Sum', Sum)
if x==Sum:
print(x,'is an Arm Number')
3
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to generate the Armstrong numbers is written and executed and its output is
verified theoretically and practically.
4
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
FIBONACCI SERIES
Ex. No.: 03
Date:
Aim:
Write a python program to generate Fibonacci Number and verify the result practically.
Software Required:
Python IDLE Version 3
Program:
#Fibonacci Series
def Fibo(Limit):
v1=0
v2=1
v3=0
for i in range(0,Limit):
v3=v2+v1
if v3>=Limit:
break
print(v3)
v1=v2
v2=v3
print("Program to Generate Fibonacci Series")
while 1:
Limit=int(input("Enter the range of Fibonacci Series :"))
Fibo(Limit)
5
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to generate the numbers of Fibonacci is written and executed and its output is
verified theoretically and practically.
6
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
CHECK THE GIVEN STRING IS PALINDROME
Ex. No.: 04
Date:
Aim:
Write a python program to check the given string is palindrome or not and verify the result
practically.
Software Required:
Python IDLE Version 3
Program:
# String is a palindrome
while 1:
Str1=input("Enter the word to check for palindrome: ")
Str2=""
for i in range(1,len(Str1)+1):
Str2=Str2+Str1[i*(-1)]
print("Reversed String is: ",Str2)
if(Str1==Str2):
print("The Given String ", Str1 , "is
Palindrome") else:
print("The Given String ", Str1 , "is not Palindrome")
7
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to check the given string is palindrome or not is written and executed and its
output is verified theoretically and practically.
8
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
DISTANCE BETWEEN TWO POINTS
Ex. No.: 05
Date:
Aim:
Write a python program to determine the distance between two points (x1,y1) and (x2,y2) and
verify the result practically.
Software Required:
Python IDLE Version 3
Program:
#This program is to determine
#the Distance between two points(Straight Line)
#Distance=Sqrt((x2-x1)^2+(y2-y1)^2)
import math
print("****This program will find the distance between two points***")
print("Give x1 input value")
x1=int(input())
print("Give x2 input value")
x2=int(input())
print("Give y1 input value")
y1=int(input())
print("Give y2 input value")
y2=int(input())
Distance=float([Link](((x2-x1)**2)+((y2-y1)**2)))
print("Distance Between Two Points",Distance)
print("End of Program")
9
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to determine the distance between two points (x1, y1) and (x2, y2) is written
and executed and its output is verified theoretically and practically.
10
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
GREATEST COMMON DIVISIOR
Ex. No.: 06
Date:
Aim:
Write a python program to find the greatest common divisor between two numbers and verify
the result practically.
Software Required:
Python IDLE Version 3
Program:
#PROGRAM TO FIND THE GREATEST COMMON DIVISOR
def GCD(m1,n1):
for i in range(1,min(m1,n1)+1):
if ((m1%i)==0 and (n1%i)==0):
[Link](i)
return ComNum[-2] # Access the Last Maximum Element
ComNum=[] # Creating Empty list
print("Program to find the Greatest Common Divisor")
print("Type the Input Number for m")
m=int(input())
print("Type the Input Number for n")
n=int(input())
GcdNumber=GCD(m,n)
print("The Common Divisors are ",ComNum)
print("Greatest Common Divisor is: ", GcdNumber)
11
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to determine the greatest common divisor between two numbers is written and
executed and its output is verified theoretically and practically.
12
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
MATRIX OPERATIONS
Ex. No.: 07
Date:
Aim:
Write a python program to perform matrix operations such as addition, subtraction and transpose,
and verify the result practically.
Software Required:
Python IDLE Version 3
Program:
i. Matrix Addition
# Program to add two matrices using nested
loop X = [[12,7,3],[4 ,5,6],[7,8,9]]
Y = [[5,8,1],[6,7,3],[4,5,9]]
result = [[0,0,0],[0,0,0],[0,0,0]]
# iterate through rows
for i in range(len(X)):
# iterate through columns
for j in range(len(X[0])):
result[i][j] = X[i][j] +Y[i][j]
print("Program to perform Matrix addition")
print(X)
print(Y)
print(result)
13
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
ii. Matrix Subtraction
# Program to add two matrices using nested
loop X = [[12,7,3],[4 ,5,6],[7,8,9]]
Y = [[5,8,1],[6,7,3],[4,5,9]]
result = [[0,0,0],[0,0,0],[0,0,0]]
# iterate through rows
for i in range(len(X)):
# iterate through columns
for j in range(len(X[0])):
result[i][j] = X[i][j] -Y[i][j]
print("Program to perform Matrix addition")
print(X)
print(Y)
print(result)
iii. Matrix Transpose
#Progrm to find the transpose of a Matrix
t = [[1,2,4,5], [9,2,3,5], [3,4,4,7], [5,6,9,7]]
def transpose(m):
row=len(m)
col=len(m[0])
result = [[0 for x in range(col)] for x in range(row)]
for i in
range(row):
for j in
range(col):
result[j][i]=m[i][j]
return result
print("Progrm to find the transpose of a Matrix")
print (t)
print (transpose(t))
14
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
i. Matrix Addition
ii. Matrix Subtraction
15
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
iii. Matrix Transpose
Result:
The Python program to perform various matrix operations such addition, subtraction, transpose was
written and executed and its output is verified theoretically and practically.
16
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
SORTING
Ex. No.: 08
Date:
Aim:
Write a python program to arrange the given numbers/words in ascending/Descending order
and verify the result practically.
Software Required:
Python IDLE Version 3
Program:
#Simple Sorting Program using Bubble sorting method
#Sorting numbers
List=[32,56,45,3,67,89,34]
print(List)
for j in range(0,(len(List)-1)):
for i in range(0,(len(List)-1)):
if(List[i]> List[i+1]): #Ascendin order for Descending order (<)
Temp1=List[i+1]
List[i+1]=List[i]
List[i]=Temp1
print(List)
print("The Lrgest Number in the List is ",List[-1] )
print("The Smllest Number in the List is ",List[0] )
#Sorting string using inbuild Method
cars = ['Ford','BMW','Volvo','Maruti','Mahindra']
print(cars)
[Link]()
print(cars)
17
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to sort the given numbers/words in ascending/descending order is written and
executed and its output is verified theoretically and practically.
18
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
PROGRAM TO FIND THE AREA OF SHAPES
Ex. No.: 09
Date:
Aim:
Write a python program to find the area of shapes and verify the result practically.
Software Required:
Python IDLE Version 3
Program:
#Program to find AREA of shape
import time
Shapes=('Triange','Square','Circle','Rectangle')
def AreaTriangle(l,b):
print("Area of Triangle is ",0.5*l*b)
def AreaSquare(l):
print("Area of Square is ", l*l)
def AreaCircle(r):
print("Area of Circle is ", 2*3.14*r)
def AreaRectangle(l,w):
print("Area of Rectangle is ",l*w)
while 1:
print("Finidng Area of Triangle,Square,Circle,Rectangle ")
Shape=str(input("Type the shape to find the Area "))
if (Shape=="Triangle"):
[Link](2)
#base=int(input("Enter the Base Value "))
print("Enter the Base Value ")
base=int(input())
[Link](2)
print("Enter the hight Value ")
hight=int(input())
19
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
AreaTriangle(base,hight)
elif (Shape=="Square"):
[Link](2)
length=int(input("Enter the Length of Side "))
AreaSquare(length)
elif (Shape=="Circle"):
[Link](2)
radius=int(input("Enter the radius of Circle "))
AreaCircle(radius)
elif(Shape=="Rectangle"):
[Link](2)
length=int(input("Enter the length of Rectangle "))
Width=int(input("Enter the width of Rectangle "))
AreaRectangle(length,Width)
else:
print("Wrong Shape Entered")
print("\n")
20
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to find the Area of few shapes is written and executed and its output is verified
theoretically and practically.
21
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
PROGRAM TO CHECK THE TRIANGLE IS RIGHT ANGLE
Ex. No.: 10
Date:
Aim:
Write a python program check that the dimensions given for the triangle are for right angle
triangle and verify the result.
Software Required:
Python IDLE Version 3
Program:
#progrm to find three sides of tringle is equal
while (1):
a=int(input("enter first side"))
b=int(input("enter second side"))
c=int(input("enter third side"))
if ((a**2+b**2)==(c**2)):
print ("it is a right angle triangle")
else:
print ("it is not a right angle triangle")
22
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to verify that the given dimensions for the triangle are for right angled triangle
is verified theoretically and practically.
23
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
FILE OPERATIONS
Ex. No.: 11
Date:
Aim:
Write a python program to perform read/write operations with respect to File and verify the
result.
Software Required:
Python IDLE Version 3
Program:
#File operations
list=['Apple','bananna','Grapes','Pumpkin']
Tuple=('United', 'institute',' of', 'Technology')
number_of_words=0
f = open("D:\[Link]","a")
for i in range(len(list)):
[Link](list[i])
[Link]("\n")
[Link](Tuple[i])
#[Link]("\n")
[Link]()
f=open("D:\[Link]","r")
data=[Link]()
print(data)
lines=[Link]()
print(data)
number_of_words += len(lines)
print(number_of_words)
print(lines)
24
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to perform read/write operations with respect to file is written and executed
and its verified theoretically and practically.
25
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Ex. No.: 12 DATE AND TIME
Date:
Aim:
Write a python script to print the current date in following format “Sun May 29 02:26:23 2017”
IST and verify the result practically.
Software Required:
Python IDLE Version 3
Program:
#Date and time Print
import time
while (1):
DateTime=[Link]()
print([Link](DateTime))
26
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to print the data and time information in the give format is written and
executed and its output is verified theoretically and practically.
27
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Ex. No.: 13 CONSTRUCTING PATTERN
Date:
Aim:
Write a python script to generate output in the desired pattern s given below and verify the result
practically.
*
**
***
****
*****
*****
****
***
**
*
Software Required:
Python IDLE Version 3
Program:
#Pattern Generation b='*'
for j in range(2):
for i in
range(6):
if j==0:
c=b*i
print(c)
if j==1:
c=b*(5-i)
print(c)
28
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to print the pattern in the given format is written and executed and its output is
verified theoretically and practically.
29
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
GENERATION OF PRIME NUMBERS
Ex. No.: 14
Date:
Aim:
Write a python program to generate prime numbers as per the limit and verify the result
practically.
Software Required:
Python IDLE Version 3
Program:
#Prime Number Program
lower_value = int(input ("Please, Enter the Lowest Range Value: "))
upper_value = int(input ("Please, Enter the Upper Range Value: "))
print ("The Prime Numbers in the range are: ")
for number in range (lower_value, upper_value + 1):
if number > 1:
for i in range (2, number):
if (number % i) == 0:
break
else:
print (number)
30
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to generate prime numbers is written and executed and its output is verified
theoretically and practically.
31
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
REMOVING DUPLICATE ELEMENTS
Ex. No.: 15
Date:
Aim:
Write a python program to generate remove duplicate element from a list and verify the result
practically.
Software Required:
Python IDLE Version 3
Program:
#Remove Duplicate Elements from the list k=(3,1,3,5,7,5,7)
def remdup(l):
List=l
Empty=[]
for i in range(0,len(List)):
dt=List[i]
if dt not in Empty:
[Link](dt)
return Empty
print(k)
print(remdup(k))
32
UNITED INSTITUTE OF TECHNOLOGY
(An Autonomous Institution)
(Approved by AICTE | Affiliated to Anna University
Accredited by NAAC with A+ Grade | Certified by ISO 9001:2015)
Periyanaickenpalayam, Coimbatore - 641020
Input/Output:
Result:
The Python program to remove duplicate elements from a non-empty list is written and executed
and its output is verified theoretically and practically.
33