TAMILNADU GOVERNMENT POLYTECHNIC COLLEGE
(AUTONOMOUS)
MADURAI – 625 011
DEPARTMENT OF WEB DESIGNING
NAME :
REGISTER
:
NUMBER
YEAR / SEM :
57440 – PYTHON PROGRAMMING
1
TAMILNADU GOVERNMENT POLYTECHNIC COLLEGE
(AUTONOMOUS)
MADURAI – 625 011
DEPARTMENT OF WEB DESIGNING
BONAFIDE CERTIFICATE
Name………………………………………………………………… [Link]……………………………
Roll No………………………………………………………………. Semester…………………………..
Certified that this is a bonafide record of work done
by…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………….. in the
…………………………………………………………………………………………………………………
during the year 2025 - 2026.
RECORD MARKS
Signature of Lab in-Charge Head of the Department
Submitted for the practical Examination held on…………………………………………………………..
Internal Examiner External Examiner
2
LIST OF EXPERIMENTS
RECORD
[Link]. DATE TITLE OF THE EXPERIMENT MARK SIGNATURE
(10)
1. Find the greatest of three numbers
Find the sum of N numbers using range() in
2.
for loop
3. Demonstrate String methods
4. Sort a tuple by converting it into a list
Check whether a key or value exist in the
5.
Dictionary
6. Array slicing in 2D array using Numpy
Search an element in 2D array using
7.
where()
Demonstrate aggregation functions in a
8.
2D array
9. Read a text file and write it in another file
10. Read a csv file and print it using pandas
RECORD AVERAGE:
3
[Link].1
DATE:
Write a python program to read three numbers and print the greatest of
three numbers.
AIM
To write a python program to read three numbers and print the greatest of three numbers.
PROGRAM
print ("Enter three numbers...")
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
c = int(input("Enter the third number: "))
if (a >= b and a >= c):
print ("A is the greatest number")
elif(b>=a and b>=c):
print ("B is the greatest number")
else:
print ("C is the greatest number")
OUTPUT
RESULT
Thus the python program to read three numbers and print the greatest of three numbers was executed
successfully and the results were noted after careful observation and verified.
4
[Link]. 2
DATE:
Write a python program to find the sum of N number using range()
function in for loop.
AIM
To write a python program to find the sum of N numbers using range()function in for loop.
PROGRAM
print ("Find the sum of n numbers")
n = int(input("Enter the n value:"))
sum = 0
for i in range(n+1):
sum = sum + i
print (" The sum of ", n, "numbers is: ", sum)
OUTPUT
RESULT
Thus the python program to find the sum of N numbers using range()function in for loop
was executed successfully and the results were noted after careful observation and verified.
5
[Link]. 3
DATE:
Write a python program to demonstrate the string slicing, concatenation,
replication and len() method.
AIM
To write a python program to demonstrate the string slicing, concatenation, replication and len()
method.
PROGRAM
ch = int(input("[Link] Slicing\n [Link] Concatenation\n [Link] replication\n
[Link] the string length\n Enter ur choice:"))
if(ch == 1):
string = input("Enter a string:")
a = int(input("Enter starting index:"))
b = int(input("Enter ending index:"))
print (string[a:b])
elif(ch==2):
string1 = input("Enter the 1st string:")
string2 = input("Enter the 2nd string:")
print ("Concatenated String is", string1 + string2)
elif(ch==3):
string = input("Enter a string:")
n = int(input("No of times to be replicated:"))
print (string * n)
elif(ch==4):
string = raw_input("Enter the string for which length is to be calculated:")
print ("The length of the string is ",len(string))
else:
print ("Enter a valid choice [1-4] !!!")
OUTPUT
6
RESULT
Thus the python program to demonstrate the string slicing, concatenation, replication and
len()method was executed successfully and the results were noted after careful observation and
verified.
7
[Link]. 4
Date:
Write a python program to create a tuple and convert into a list and print the
list in sorted order.
AIM
To write a python program to create a tuple and convert into a list and print the list in sorted order.
PROGRAM
tuple1 = (6,7,8,9,10,1,2,3,4,5)
print ("The created tuple is: ", tuple1)
list1 = list(tuple1)
print ("Tuple converted to list is:", list1)
[Link]()
print ("The list in ascending order is: ", list1)
OUTPUT:
RESULT
Thus the python program to create a tuple and convert into a list and print the list in sorted order
was executed successfully and the results were noted after careful observation and verified.
8
[Link]. 5
Date:
Write a python program to create a dictionary and check whether a key
or value exist in the dictionary.
AIM
To write a python Program to create a dictionary and check whether a key or value exist in the
dictionary.
PROGRAM
student = {"name": "Kishore", "rollno": 25, "course": "Python"}
print("Dictionary:", student)
key = "rollno"
if key in [Link]():
print("Key exists in the dictionary")
else:
print("Key does not exist in the dictionary")
value = "Python"
if value in [Link]():
print("Value exists in the dictionary")
else:
print("Value does not exist in the dictionary")
OUTPUT
RESULT
Thus the python program to create a dictionary and check whether a key or value exist in the
dictionary was executed successfully and the results were noted after careful observation and verified.
9
[Link]. 6
Date:
Write a python program to create one dimensional and convert into a
2 dimensional array using reshape(), print the first two columns alone
using slicing.
AIM
To write a python program to create one dimensional and convert into a 2 dimensional array using
reshape(), print the first two columns alone using slicing.
PROGRAM
import numpy as np
# Create one-dimensional array (a1)
a1 = [Link]([1, 2, 3, 4, 5, 6, 7, 8, 9])
# Convert 1D array into 2D array (a2) using reshape()
a2 = [Link](3, 3)
print("Two Dimensional Array:")
print(a2)
print("\nFirst Two Columns:")
print(a2[0:3, 0:2])
OUTPUT
RESULT
Thus the python program to create one dimensional and convert into a 2 dimensional array
using reshape(), print the first two columns alone using slicing was executed successfully and the
results were noted after careful observation and verified.
10
[Link]. 7
Date:
Write a python program to create two dimensional array and search for
an element using where() function.
AIM
To write a python program to create two dimensional array and search for an element using
where() function.
PROGRAM
import numpy as np
a = [Link]([
[10,20,30],
[40,50,60],
[70,80,90]])
print("The 2D array is :\n", a)
key = 10
pos = [Link](a==key)
print("The index of the key is", pos)
OUTPUT
RESULT
Thus the python program to create two dimensional array and search for an element using
where() function was executed successfully and the results were noted after careful observation and
verified.
11
[Link]. 8
Date:
Write a python program to create a two-dimensional array and
demonstrate aggregation functions sum( ), min( ) and max( ) in the row and
column wise.
AIM
To write a python program to create a two- d i m e n s i o n a l array and demonstrate aggregation
functions sum(), min() and max() in the row and column wise.
PROGRAM
import numpy as np
# 2 x 2 matrix
a = [Link]([[1, 2],
[3, 4]])
# Column wise
print(" Column wise")
print("Sum = ", [Link](a, axis = 0))
print("Min = ", [Link](a, axis = 0))
print("Max = ", [Link](a, axis = 0))
# Row wise
print("\n Row wise")
print("Sum = ", [Link](a, axis = 1))
print("Min = ", [Link](a, axis = 1))
print("Max = ", [Link](a, axis = 1))
OUTPUT
RESULT
Thus the python program to create a two- d i m e n s i o n a l array and demonstrate
aggregation functions sum(), min() and max() in the row and column wise was executed
successfully and the results were noted after careful observation and verified.
12
[Link]. 9
Date:
Write a python program to read a text file and write the content in another
file.
AIM
To write a python program to read a text file and write the content in another file.
PROGRAM
f1 = open("[Link]",'r')
x = [Link]()
print("\n The content of source file is: \n ", x)
f2 = open("[Link]",'w')
[Link](x)
f2 = open("[Link]",'r')
print("\n The content of copied file is: \n ", [Link]())
OUTPUT
RESULT
Thus the python program to read a text file and write the content in another file was executed
successfully and the results were noted after careful observation and verified.
13
[Link]. 10
Date:
Write a python program to read a csv file using pandas and print the content.
AIM
To write a python program to read a csv file using pandas and print the content.
PROGRAM
import pandas as pd
f1 = pd.read_csv(“[Link]”)
print(“The contents in csv file are:”)
print(f1.to_string())
OUTPUT
RESULT
Thus the python program to read a csv file using pandas and print the content was executed
successfully and the results were noted after careful observation and verified.
14