SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
FACULTY OF SCIENCE AND HUMANITIES
DEPARTMENT OF COMPUTER APPLICATIONS
PRACTICAL RECORD NOTE
STUDENT NAME :
REGISTER
:
NUMBER
CLASS : Section :
YEAR &
SEMESTER :
SUBJECT CODE :
SUBJECT TITLE :
OCTOBER 2025
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
FACULTY OF SCIENCE AND HUMANITIES
DEPARTMENT OF COMPUTER APPLICATIONS
SRM Nagar, Kattankulathur – 603 203
CERTIFICATE
Certified to be the bonafide record of practical work done by
Register No. of Degree course for
UCA23501J – PYTHON PROGRAMMING in the Computer lab in SRM Institute of
Science and Technology during the academic year 2025-2026.
Staff In-charge Head of the Department
Submitted for Semester Practical Examination held on .
Internal Examiner External Examiner
S. Page Sign
No Date Title No.
10
11
12
13
14
15
Ex. No.: 01
Date:
Program for Matrix Representation
AIM:
To understand and represent matrices as rectangular arrangements of data defined by rows
and columns, where each entry can be integers, floating-point numbers, or complex numbers.
Algorithm:
Code:
n = int(input())
m = int(input())
list = []
for i in range(0, n*m):
[Link](int(input()))
for i in range(0, n*m):
if i%m == 0:
print()
print(list[i], end=" ")
Output:
Result:
Ex. No.: 02
Date:
Program to Separate and Display Even and Odd Number
AIM:
To display the even and odd numbers separately from the given set of numbers.
Algorithm:
Code:
n = int(input())
even = []
odd = []
for i in range(0, n):
num = int(input())
if num%2 == 0:
[Link](num)
else:
[Link](num)
for i in even:
print(i, end=" ")
print()
for i in odd:
print(i, end=" ")
Output:
Result:
Ex. No.: 03
Date:
Program to Compute Roots of a
Quadratic Equation Numerically
AIM:
To find the roots of a quadratic equation using numerical computation, handling both real and
complex roots.
Algorithm:
Code:
import cmath
a = float(input())
b = float(input())
c = float(input())
d = (b**2) - (4*a*c)
sol1 = (-b - [Link](d)) / (2 * a)
sol2 = (-b + [Link](d)) / (2 * a)
def format_complex(num):
real = [Link]
img = [Link]
if img == 0:
return f"{real:.2f}"
elif real == 0:
return f"{imag:.2f}i"
else:
operator = "+" if img >= 0 else "-"
return f"{real:.2f} {operator} i{abs(img):.2f}"
res1 = format_complex(sol1)
res2 = format_complex(sol2)
print(f"{res2} and {res1}")
Output:
Result:
Ex. No.: 04
Date:
Program to Calculate Luggage Charges
Based on Weight Threshold
AIM:
To calculate luggage charges based on a threshold weight, applying different charges for
weights exceeding the threshold.
Algorithm:
Code:
def weightMachine(N,weights,T):
price = 0
for weight in weights:
if weight > T:
price += 2
else:
price += 1
return price
n = int(input())
weights = []
for i in range(n):
[Link](int(input()))
t = int(input())
print(weightMachine(n, weights, t))
Output:
Result:
Ex. No.: 05
Date:
Program to Check if a String Contains Both
Letters and Numbers
AIM:
To understand and represent matrices as rectangular arrangements of data defined by rows
and columns, where each entry can be integers, floating-point numbers, or complex numbers.
Algorithm:
Code:
n = int(input())
for i in range(0, n):
str1=str(input())
alpha = False
digit = False
count = 0
for i in str1:
if not alpha:
alpha = [Link]()
if not digit:
digit = [Link]()
if alpha and digit:
print("True")
break
if count == (len(str1)-1):
print("False")
count += 1
Output:
Result:
Ex. No.: 06
Date:
Program to Invert the Case of Characters in a String
AIM:
Invert the case of each alphabetic character within a string, converting uppercase letters to
lowercase and lowercase letters to uppercase
Algorithm:
Code:
ch=str(input())
str2 = ""
for c in ch:
if [Link]():
str2 += [Link]()
else:
str2 += [Link]()
print(str2)
Output:
Result:
Ex. No.: 07
Date:
Program to Find Maximum Adjacent Opposite Pairs
AIM:
To find the maximum number of adjacent opposite pairs that can be formed in a row of
students, where each pair consists of different types (e.g., boys and girls).
Algorithm:
Code:
t = int(input())
for tc in range(0, t):
count, n = 0, 0
students=str(input())
i=len(students)
while n < i-1:
if (students[n] == "g" and students[n+1] == "b") or (students[n] == "b" and students[n+1] == "g"):
count += 1
n += 2
else:
n += 1
print(count)
Output:
Result:
Ex. No.: 08
Date:
Program to Calculate Min-Max String Difference
AIM:
To calculate the minimum and maximum differences between two strings containing wildcards
(‘?’), by replacing them with appropriate characters.
Algorithm:
Code:
n = int(input())
for _ in range(n):
s1=str(input())
s2=str(input())
min_diff = max_diff = 0
q1 = q2 = 0
null = len(s1)
for c1, c2 in zip(s1, s2):
if c1 == '?' or c2 == '?':
max_diff += 1
elif c1 != c2:
min_diff += 1
max_diff += 1
print(min_diff, max_diff)
Output:
Result:
Ex. No.: 09
Date:
Program for Various String Operations
AIM:
To calculate the minimum and maximum differences between two strings containing wildcards
(‘?’), by replacing them with appropriate characters.
Algorithm:
Code:
def check(string, sub_string):
return [Link](sub_string)
str1=input()
str2=input()
print(str1+str2)
print(str1+str1)
print(str2+str2)
print(not(check(str1, str2)))
print(not(check(str2, str1)))
print(not(not(check(str1, str2))))
print(not(not(check(str2, str1))))
Output:
Result:
Ex. No.: 10
Date:
Program to Count All Substring Occurrences in a String
AIM:
To count the number of times a substring occurs in a string, including overlapping occurrences.
Algorithm:
Code:
def check(str, substr):
i=0
count = 0
while i < (len(str)):
if substr in str:
count += 1
str = str[i:]
i = ([Link](substr)+1)
else:
i += 1
return count-1
str = input()
substr = input()
print(check(str, substr))
Output:
Result:
Ex. No.: 11
Date:
Program to Check the Validity of a 10-Character ISBN Code
AIM:
To check the validity of a 10-character ISBN code using the weighted sum method and determine
if it is divisible by 11.
Algorithm:
Code:
def isbin(isbn):
if len(isbn) != 10:
return "Invalid"
else:
total = 0
for j in range(10):
if isbn[j] == 'X':
total += 10 * (10-j)
else:
total += int(isbn[j]) * (10-j)
if total % 11 == 0:
return "Valid"
else:
return "Invalid"
t = int(input())
for i in range(t):
isbn = input()
print(isbin(isbn))
Output:
Result:
Ex. No.: 12
Date:
Program to Check if a Sentence is a Pangram
AIM:
AIM: To determine whether a given sentence is a pangram, i.e., contains all 26 letters of the
English alphabet at least once.
Algorithm:
Code:
def is_pangram(str):
used = [False] * 26
for char in str:
if [Link]():
i = ord(char) - ord('a')
used[i] = True
if all(used):
return "panagram"
else:
return "not a panagram"
str = input().lower()
print(is_pangram(str))
Output:
Result:
Ex. No.: 13
Date:
Program to Count Vowels in a String
AIM:
To count the total number of vowels (a, e, i, o, u) in a given string, treating uppercase and
lowercase vowels equally.
Algorithm:
Code:
class vowel:
def __init__(self):
[Link] = 0
def count_vowel(self):
str = input("Enter string:")
for s in str:
if s in ['a', 'e', 'i', 'o', 'u']:
[Link] += 1
print("Count of the vowel is:")
print([Link])
v = vowel()
v.count_vowel()
Output:
Result:
Ex. No.: 14
Date:
Program to Swap Two Strings Using a Class
AIM:
To count the total number of vowels (a, e, i, o, u) in a given string, treating uppercase and
lowercase vowels equally.
Algorithm:
Code:
class swap:
def __init__(self):
[Link] = ""
def swap(self):
fruit1 = input()
fruit2 = input()
print("Before swap")
print("First String=", fruit1)
print("Second String=", fruit2)
[Link] = fruit1
fruit1 = fruit2
fruit2 = [Link]
print("After swap")
print("First String=", fruit1)
print("Second String=", fruit2)
s = swap()
[Link]()
Output:
Result:
Ex. No.: 15
Date:
Program to Develop a Simple Calculator
AIM:
To develop a simple calculator program that performs basic arithmetic operations (addition,
subtraction, multiplication, division) on two numbers provided by the user.
Algorithm:
Code:
class calculator:
def __init__(self):
pass
class result(calculator):
def __init__(self, n):
super().__init__()
self.n = n
def add(self, n1, n2):
res, op = 0, ""
if self.n == "1":
print(f"{n1} + {n2} = {n1+n2}")
elif self.n == "2":
print(f"{n1} - {n2} = {n1-n2}")
elif self.n == "3":
print(f"{n1} * {n2} = {n1*n2}")
else:
print(f"{n1} / {n2} = {n1/n2}")
obj = result(input())
num1, num2 = int(input()), int(input())
[Link](num1,num2)
Output:
Result: