0% found this document useful (0 votes)
16 views63 pages

Python Programming Lab Certificate

The document is a practical work certificate for a student named Somanaboina Bhargava Sai Ram from the Internet of Things department at VNR VJIET, covering the academic years 2024-2028. It includes an index of various Python programming experiments completed by the student, with details such as experiment names, submission dates, and status. Each experiment is accompanied by submitted code and test cases demonstrating the functionality of the code.

Uploaded by

mjrao2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views63 pages

Python Programming Lab Certificate

The document is a practical work certificate for a student named Somanaboina Bhargava Sai Ram from the Internet of Things department at VNR VJIET, covering the academic years 2024-2028. It includes an index of various Python programming experiments completed by the student, with details such as experiment names, submission dates, and status. Each experiment is accompanied by submitted code and test cases demonstrating the functionality of the code.

Uploaded by

mjrao2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

53

69
1A
07
24

Name: SOMANABOINA BHARGAVA SAI RAM Department: Internet of Things - IoT

Roll No: 24071A6953 Laboratory: PYTHON PROGRAMMING


LABORATORY

VNR VJIET Powered by [Link]


Certificate that is the bonafied record of the practical work done during the

academic Year 2024 - 2028 by the student Name "SOMANABOINA BHARGAVA

SAI RAM " [Link] "24071A6953" Class ........... in the Laboratory "PYTHON

PROGRAMMING LABORATORY" Department of "Internet of Things - IoT"

Signature of the Head of the Dept. Signature of the Staff Member

Date of Examination: ..........

Signature of the Examiners

Internal Examiner External Examiner

VNR VJIET Powered by [Link]


INDEX :

Exp# Experiment Name Date Remarks Status

1 Distance Between Two Points 31/07/2025 No Submitted


Remarks

2 Compound Interest Calculator 31/07/2025 No Submitted


Remarks

3 Person Details Input and Display 31/07/2025 No Submitted


Remarks

4 Character Type Classifier 31/07/2025 No Submitted


Remarks

5 Fibonacci Sequence Generator 31/07/2025 No Submitted


53 Remarks

6 Prime Numbers in Interval 07/08/2025 No Submitted


Remarks
69

7 Descending Number Triangle 07/08/2025 No Submitted


Pattern Remarks
1A

8 LCM Calculator 07/08/2025 No Submitted


Remarks
07

9 Command Line Addition 07/08/2025 No Submitted


Remarks
24

10 List and Tuple to Array Conversion 11/09/2025 No Submitted


Remarks

11 Common Values Between Two 11/09/2025 No Submitted


Arrays Remarks

12 Create Tuple with Different Data 11/09/2025 No Submitted


Types Remarks

VNR VJIET Powered by [Link]


Exp# Experiment Name Date Remarks Status

13 Python Tuple Creation and 11/09/2025 No Submitted


Operations Remarks

14 Palindrome String Checker 11/09/2025 No Submitted


Remarks

15 Greatest Common Divisor (GCD) 07/08/2025 No Submitted


Function Remarks

16 Statistical Measures Calculator 11/09/2025 No Submitted


Remarks

17 Element Existence Check in Tuple 11/09/2025 No Submitted


Remarks

18 Check String Palindrome 11/09/2025 No Submitted


Remarks

19 Remove Word from String 11/09/2025 No Submitted


Remarks

20 Generate N-Bit Binary Strings 15/10/2025 No Submitted


Remarks

21 Implement Set Operations 11/09/2025 No Submitted


Remarks

22 Is List Sorted Checker 11/09/2025 No Submitted


Remarks

23 Duplicate Element Checker 11/09/2025 No Submitted


Remarks

24 Invert Dictionary 11/09/2025 No Submitted


Remarks

VNR VJIET Powered by [Link]


Exp# Experiment Name Date Remarks Status

25 Capitalize First Letter of Words 11/09/2025 No Submitted


Remarks

26 Remove Duplicates from List 11/09/2025 No Submitted


Remarks

27 Add Commas Between Characters 11/09/2025 No Submitted


Remarks

28 Cumulative Product Calculator 15/10/2025 No Submitted


Remarks

29 List Reverse Function 15/10/2025 No Submitted


Remarks

30 Matrix Printer 15/10/2025 No Submitted


Remarks

31 Square Matrix Addition 15/10/2025 No Submitted


Remarks

32 Factorial Calculator using 15/10/2025 No Submitted


Recursion Remarks

33 Factorial Calculator using 15/10/2025 No Submitted


Recursion Remarks

34 Square Matrix Multiplication 15/10/2025 No Submitted


Remarks

35 Simple Calculator Using Functions 15/10/2025 No Submitted


Remarks

VNR VJIET Powered by [Link]


Exp: Distance Between Two Points

Problem 1:
Distance Between Two Points
Submitted Code:
import math
x1, y1, x2, y2 = map(float, input().split())
d = [Link](x2 - x1, y2 - y1)
print(f"{d:.2f}")

53
Testcase 1
Input:
0034
Expected Output:
5.00
Actual Output:
69
1A
5.00
07

Testcase 2
Input:
24

1145
Expected Output:
5.00
Actual Output:
5.00

VNR VJIET Powered by [Link]


Exp: Compound Interest Calculator

Problem 2:
Compound Interest Calculator
Submitted Code:
P, R, T = map(float, input().split())
T = int(T)
A = P * (1 + R/100) ** T
print(f"{A:.2f}")

53
Testcase 1
Input:
1000 10 5

69
Expected Output:
1610.51
Actual Output:
1A
1610.51
07

Testcase 2
Input:
5000 8 3
24

Expected Output:
6298.56
Actual Output:
6298.56

VNR VJIET Powered by [Link]


Exp: Person Details Input and Display

Problem 3:
Person Details Input and Display
Submitted Code:
name = input()
address = input()
email = input()
phone = input()
print(f"Name: {name}")

53
print(f"Address: {address}")
print(f"Email: {email}")
print(f"Phone: {phone}")

Testcase 1
Input: 69
1A
John Doe
123 Main Street, Cityville
[Link]@[Link]
07

+1-555-1234
Expected Output:
Name: John Doe
24

Address: 123 Main Street, Cityville


Email: [Link]@[Link]
Phone: +1-555-1234
Actual Output:
Name: John Doe
Address: 123 Main Street, Cityville
Email: [Link]@[Link]
Phone: +1-555-1234

VNR VJIET Powered by [Link]


Testcase 2
Input:
Alice Smith
456 Park Avenue, Townsburg
alice_smith@[Link]
9876543210
Expected Output:
Name: Alice Smith

53
Address: 456 Park Avenue, Townsburg
Email: alice_smith@[Link]
Phone: 9876543210

69
Actual Output:
Name: Alice Smith
Address: 456 Park Avenue, Townsburg
1A
Email: alice_smith@[Link]
Phone: 9876543210
07
24

VNR VJIET Powered by [Link]


Exp: Character Type Classifier

Problem 4:
Character Type Classifier
Submitted Code:
ch = input()[0]
if ch >= '0' and ch <= '9':
print('Digit')
elif ch >= 'a' and ch <= 'z':
print('Lowercase Character')

53
elif ch >= 'A' and ch <= 'Z':
print('Uppercase Character')
else:

69
print('Special Character')

Testcase 1
1A
Input:
a
Expected Output:
07

Lowercase Character
Actual Output:
Lowercase Character
24

Testcase 2
Input:
5
Expected Output:
Digit
Actual Output:
Digit

VNR VJIET Powered by [Link]


Exp: Fibonacci Sequence Generator

Problem 5:
Fibonacci Sequence Generator
Submitted Code:
n = int(input())
a, b = 0, 1
count = 0
while count < n:
# Last term: print without trailing space

53
print(a, end=' ')
a, b = b, a + b
count += 1

Testcase 1
Input: 69
1A
5
Expected Output:
01123
07

Actual Output:
01123
24

Testcase 2
Input:
3
Expected Output:
011
Actual Output:
011

VNR VJIET Powered by [Link]


Exp: Prime Numbers in Interval

Problem 6:
Prime Numbers in Interval
Submitted Code:
start, end = map(int, input().split())
primes = []
for num in range(start, end + 1):
if num < 2:
continue

53
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
break

69
else:
[Link](num)
if primes:
1A
for p in primes:
print(p)
else:
07

print("No prime numbers found")

Testcase 1
24

Input:
10 20
Expected Output:
11
13
17
19
Actual Output:
11
13
17
19

VNR VJIET Powered by [Link]


Testcase 2
Input:
1 10
Expected Output:
2
3
5
7

53
Actual Output:
2
3

69
5
7
1A
07
24

VNR VJIET Powered by [Link]


Exp: Descending Number Triangle Pattern

Problem 7:
Descending Number Triangle Pattern
Submitted Code:
# No input required; simply print the pattern
for row in range(1, 6):
num = 6 - row
print(" ".join([str(num)] * row))

53
Testcase 1
Input:

69
Expected Output:
5
44
1A
333
2222
11111
07

Actual Output:
5
44
24

333
2222
11111

VNR VJIET Powered by [Link]


Testcase 2
Input:

Expected Output:
5
44
333
2222

53
11111
Actual Output:
5

69
44
333
2222
1A
11111
07
24

VNR VJIET Powered by [Link]


Exp: LCM Calculator

Problem 8:
LCM Calculator
Submitted Code:
import math
a, b = map(int, input().split())
lcm = a * b // [Link](a, b)
print(lcm)

53
Testcase 1
Input:
12 18

69
Expected Output:
36
Actual Output:
1A
36
07

Testcase 2
Input:
57
24

Expected Output:
35
Actual Output:
35

VNR VJIET Powered by [Link]


Exp: Command Line Addition

Problem 9:
Command Line Addition
Submitted Code:
# Read two integers from standard input and print their sum
a, b = map(int, input().split())
print(a + b)

Testcase 1

53
Input:
53
Expected Output:

69
8
Actual Output:
8
1A
Testcase 2
07

Input:
-2 7
Expected Output:
24

5
Actual Output:
5

VNR VJIET Powered by [Link]


Exp: List and Tuple to Array Conversion

Problem 10:
List and Tuple to Array Conversion
Submitted Code:
N, M = map(int, input().split())
list_input = input().split()
tuple_input = input().split()
# Function to detect type and format elements
def format_array(elements):

53
# Check if elements are all integers
if all([Link]('-').isdigit() for e in elements):
elements = [int(e) for e in elements]

69
return '[' + ' '.join(map(str, elements)) + ']'
else:
# Strings: wrap each element in quotes
1A
return '[' + ' '.join(f"'{e}'" for e in elements) + ']'
print(format_array(list_input))
print(format_array(tuple_input))
07

Testcase 1
Input:
24

34
123
4567
Expected Output:
[1 2 3]
[4 5 6 7]
Actual Output:
[1 2 3]
[4 5 6 7]

VNR VJIET Powered by [Link]


Testcase 2
Input:
23
cat dog
fish bird cow
Expected Output:
['cat' 'dog']
['fish' 'bird' 'cow']

53
Actual Output:
['cat' 'dog']
['fish' 'bird' 'cow']

69
1A
07
24

VNR VJIET Powered by [Link]


Exp: Common Values Between Two Arrays

Problem 11:
Common Values Between Two Arrays
Submitted Code:
N, M = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
# Use sets to find unique common values
common_values = sorted(set(arr1) & set(arr2))

53
if common_values:
print(' '.join(map(str, common_values)))
else:

69
print('No common values found')

Testcase 1
1A
Input:
45
1234
07

2 4 6 8 10
Expected Output:
24
24

Actual Output:
24

Testcase 2
Input:
33
123
456
Expected Output:
No common values found
Actual Output:

VNR VJIET Powered by [Link]


No common values found

53
69
1A
07
24

VNR VJIET Powered by [Link]


Exp: Create Tuple with Different Data Types

Problem 12:
Create Tuple with Different Data Types
Submitted Code:
N = int(input())
elements = []
for _ in range(N):
value, dtype = input().split()
if dtype == 'i':

53
[Link](int(value))
elif dtype == 'f':
[Link](float(value))

69
elif dtype == 's':
[Link](value)
elif dtype == 'b':
1A
[Link](True if [Link]() == 'true' else False)
elif dtype == 'l':
# Convert comma-separated string into a list of integers
07

[Link]([int(x) for x in [Link](',')])


# Create tuple
result_tuple = tuple(elements)
24

# Print outputs
print(result_tuple)
print(tuple(type(x) for x in result_tuple))
print(len(result_tuple))

VNR VJIET Powered by [Link]


Testcase 1
Input:
5
42 i
3.14 f
hello s
true b
1,2,3 l

53
Expected Output:
(42, 3.14, 'hello', True, [1, 2, 3])
(<class 'int'>, <class 'float'>, <class 'str'>, <class 'bool'>, <class 'list'>)

69
5
Actual Output:
(42, 3.14, 'hello', True, [1, 2, 3])
1A
(<class 'int'>, <class 'float'>, <class 'str'>, <class 'bool'>, <class 'list'>)
5
07

Testcase 2
Input:
24

3
100 i
world s
false b
Expected Output:
(100, 'world', False)
(<class 'int'>, <class 'str'>, <class 'bool'>)
3
Actual Output:
(100, 'world', False)
(<class 'int'>, <class 'str'>, <class 'bool'>)
3

VNR VJIET Powered by [Link]


Exp: Python Tuple Creation and Operations

Problem 13:
Python Tuple Creation and Operations
Submitted Code:
N = int(input())
values = input().split()
if N == 1:
# Create tuple from space-separated integers
result = tuple(int(x) for x in values)

53
elif N == 2:
# Create tuple with mixed data types (detect integers and string
s)

69
temp = []
for v in values:
if [Link]('-').isdigit():
1A
[Link](int(v))
else:
[Link](v)
07

result = tuple(temp)
elif N == 3:
# Create tuple from another sequence (here, we assume integers)
24

result = tuple(int(x) for x in values)


elif N == 4:
# Create nested tuple
result = tuple(tuple(x) for x in values)
elif N == 5:
# Create tuple with single element
# Always add a comma to ensure it's a tuple
val = values[0]
val = int(val) if [Link]('-').isdigit() else val
result = (val,)
# Print outputs
print(result)

VNR VJIET Powered by [Link]


print(type(result))
print(len(result))

Testcase 1
Input:
1
12345
Expected Output:

53
(1, 2, 3, 4, 5)
<class 'tuple'>
5

69
Actual Output:
(1, 2, 3, 4, 5)
<class 'tuple'>
1A
5
07

Testcase 2
Input:
5
24

42
Expected Output:
(42,)
<class 'tuple'>
1
Actual Output:
(42,)
<class 'tuple'>
1

VNR VJIET Powered by [Link]


Exp: Palindrome String Checker

Problem 14:
Palindrome String Checker
Submitted Code:
import string
def palindrome(s):
# Convert to lowercase and remove non-alphanumeric characters
cleaned = ''.join([Link]() for ch in s if [Link]())
# Check if cleaned string is equal to its reverse

53
return cleaned == cleaned[::-1]
# Input
s = input()

69
print(palindrome(s))

Testcase 1
1A
Input:
A man, a plan, a canal: Panama
Expected Output:
07

True
Actual Output:
True
24

Testcase 2
Input:
race a car
Expected Output:
False
Actual Output:
False

VNR VJIET Powered by [Link]


Exp: Greatest Common Divisor (GCD) Function

Problem 15:
Greatest Common Divisor (GCD) Function
Submitted Code:
def gcd(a, b):
while b:
a, b = b, a % b
return a
if __name__ == "__main__":

53
a, b = map(int, input().split())
print(gcd(a, b))

69
Testcase 1
Input:
48 18
1A
Expected Output:
6
Actual Output:
07

6
24

Testcase 2
Input:
54 24
Expected Output:
6
Actual Output:
6

VNR VJIET Powered by [Link]


Exp: Statistical Measures Calculator

Problem 16:
Statistical Measures Calculator
Submitted Code:
from collections import Counter
# Input
N = int(input())
nums = list(map(int, input().split()))
# Mean

53
mean = round(sum(nums) / N, 2)
# Median
nums_sorted = sorted(nums)

69
if N % 2 == 1:
median = nums_sorted[N // 2]
else:
1A
median = round((nums_sorted[N//2 - 1] + nums_sorted[N//2]) / 2,
2)
# Mode
07

freq = Counter(nums)
max_count = max([Link]())
mode_candidates = [num for num, count in [Link]() if count == ma
24

x_count]
mode = min(mode_candidates)
# Output
print(f"{mean:.2f}")
if isinstance(median, float):
print(f"{median:.2f}")
else:
print(f"{median:.2f}") # Ensure 2 decimal places even for integ
er median
print(mode)

VNR VJIET Powered by [Link]


Testcase 1
Input:
6
122333
Expected Output:
2.33
2.50
3

53
Actual Output:
2.33
2.50

69
3
1A
Testcase 2
Input:
5
07

11223
Expected Output:
1.80
24

2.00
1
Actual Output:
1.80
2.00
1

VNR VJIET Powered by [Link]


Exp: Element Existence Check in Tuple

Problem 17:
Element Existence Check in Tuple
Submitted Code:
# Input reading
N = int(input())
elements = input().split()
T = input().strip()
search_value = input().strip()

53
# Convert elements based on type indicator
if T == 'i':
elements = [int(x) for x in elements]

69
search_value = int(search_value)
elif T == 'f':
elements = [float(x) for x in elements]
1A
search_value = float(search_value)
else: # string
elements = [x for x in elements]
07

# Convert to tuple
tup = tuple(elements)
# Check existence
24

if search_value in tup:
print("True")
print([Link](search_value))
print([Link](search_value))
else:
print("False")
print("Element not found")
print(0)

VNR VJIET Powered by [Link]


Testcase 1
Input:
5
12234
i
2
Expected Output:
True

53
1
2
Actual Output:

69
True
1
2
1A
Testcase 2
07

Input:
4
apple banana orange grape
24

s
kiwi
Expected Output:
False
Element not found
0
Actual Output:
False
Element not found
0

VNR VJIET Powered by [Link]


Exp: Check String Palindrome

Problem 18:
Check String Palindrome
Submitted Code:
import re
S = input()
S = [Link](r'[^A-Za-z0-9]', '', S).lower()
print("Yes" if S == S[::-1] else "No")

53
Testcase 1
Input:
A man, a plan, a canal: Panama

69
Expected Output:
Yes
Actual Output:
1A
Yes
07

Testcase 2
Input:
race a car
24

Expected Output:
No
Actual Output:
No

VNR VJIET Powered by [Link]


Exp: Remove Word from String

Problem 19:
Remove Word from String
Submitted Code:
T = input()
W = input()
words = [word for word in [Link]() if word != W]
print(' '.join(words) if words else 'Empty String')

53
Testcase 1
Input:
Hello world Hello Python Hello Java

69
Hello
Expected Output:
world Python Java
1A
Actual Output:
world Python Java
07

Testcase 2
Input:
24

apple apple apple


apple
Expected Output:
Empty String
Actual Output:
Empty String

VNR VJIET Powered by [Link]


Exp: Generate N-Bit Binary Strings

Problem 20:
Generate N-Bit Binary Strings
Submitted Code:
def generate_binary(n, prefix=""):
if n == 0:
print(prefix)
return
generate_binary(n-1, prefix + "0")

53
generate_binary(n-1, prefix + "1")
# Main program
n = int(input())

69
generate_binary(n)

Testcase 1
1A
Input:
2
Expected Output:
07

00
01
10
24

11
Actual Output:
00
01
10
11

VNR VJIET Powered by [Link]


Testcase 2
Input:
1
Expected Output:
0
1
Actual Output:
0

53
1

69
1A
07
24

VNR VJIET Powered by [Link]


Exp: Implement Set Operations

Problem 21:
Implement Set Operations
Submitted Code:
n1 = int(input())
a = list(map(int, input().split()))
set_a = []
for x in a:
if x not in set_a:

53
set_a.append(x)
n2 = int(input())
b = list(map(int, input().split()))

69
set_b = []
for x in b:
if x not in set_b:
1A
set_b.append(x)
union = set_a.copy()
for x in set_b:
07

if x not in union:
[Link](x)
print(" ".join(map(str, sorted(union))) if union else "Empty")
24

intersection = [x for x in set_a if x in set_b]


print(" ".join(map(str, sorted(intersection))) if intersection else
"Empty")
difference = [x for x in set_a if x not in set_b]
print(" ".join(map(str, sorted(difference))) if difference else "Emp
ty")
sym_diff = [x for x in union if (x in set_a) != (x in set_b)]
print(" ".join(map(str, sorted(sym_diff))) if sym_diff else "Empty")

VNR VJIET Powered by [Link]


Testcase 1
Input:
4
1234
3
345
Expected Output:
12345

53
34
12
125

69
Actual Output:
12345
34
1A
12
125
07
24

VNR VJIET Powered by [Link]


Testcase 2
Input:
3
123
3
456
Expected Output:
123456

53
Empty
123
123456

69
Actual Output:
123456
Empty
1A
123
123456
07
24

VNR VJIET Powered by [Link]


Exp: Is List Sorted Checker

Problem 22:
Is List Sorted Checker
Submitted Code:
def is_sorted(lst):
return all(lst[i] <= lst[i+1] for i in range(len(lst)-1))
n = int(input())
if n == 0:
lst = []

53
else:
lst = list(map(int, input().split()))
print(is_sorted(lst))

Testcase 1
Input: 69
1A
5
12345
Expected Output:
07

True
Actual Output:
True
24

Testcase 2
Input:
4
1324
Expected Output:
False
Actual Output:
False

VNR VJIET Powered by [Link]


Exp: Duplicate Element Checker

Problem 23:
Duplicate Element Checker
Submitted Code:
def has_duplicates(lst):
seen = set()
for item in lst:
if item in seen:
return True

53
[Link](item)
return False
n = int(input())

69
if n == 0:
elements = []
else:
1A
elements = input().split()
# Convert numeric strings to int or float if possible
for i in range(len(elements)):
07

try:
if '.' in elements[i]:
elements[i] = float(elements[i])
24

else:
elements[i] = int(elements[i])
except ValueError:
pass # Keep as string if conversion fails
print(has_duplicates(elements))

VNR VJIET Powered by [Link]


Testcase 1
Input:
5
12324
Expected Output:
True
Actual Output:
True

53
Testcase 2

69
Input:
4
apple banana orange grape
1A
Expected Output:
False
Actual Output:
07

False
24

VNR VJIET Powered by [Link]


Exp: Invert Dictionary

Problem 24:
Invert Dictionary
Submitted Code:
n = int(input())
orig_dict = {}
# Read input and store in original dictionary
for _ in range(n):
k, v = input().split()

53
# Convert numeric strings to int if possible
try:
k = int(k)

69
except ValueError:
pass
try:
1A
v = int(v)
except ValueError:
pass
07

orig_dict[k] = v
# Invert dictionary
inverted = {}
24

for key, value in orig_dict.items():


if value in inverted:
# If already a list, append; else convert to list
if isinstance(inverted[value], list):
inverted[value].append(key)
else:
inverted[value] = [inverted[value], key]
else:
inverted[value] = key
# Sort by keys (convert all keys to strings for consistent sorting)
sorted_keys = sorted([Link](), key=lambda x: str(x))
# Print output

VNR VJIET Powered by [Link]


for k in sorted_keys:
v = inverted[k]
if isinstance(v, list):
print(f"{k} : [{', '.join(map(str, v))}]")
else:
print(f"{k} : {v}")

Testcase 1

53
Input:
3
1 apple

69
2 banana
3 apple
Expected Output:
1A
apple : [1, 3]
banana : 2
Actual Output:
07

apple : [1, 3]
banana : 2
24

VNR VJIET Powered by [Link]


Testcase 2
Input:
5
red apple
green banana
blue apple
yellow cherry
black apple

53
Expected Output:
apple : [black, blue, red]
banana : green

69
cherry : yellow
Actual Output:
apple : [red, blue, black]
1A
banana : green
cherry : yellow
07
24

VNR VJIET Powered by [Link]


Exp: Capitalize First Letter of Words

Problem 25:
Capitalize First Letter of Words
Submitted Code:
def capitalize_words(sentence):
result = []
words = [Link](' ')
for word in words:
if word == '':

53
[Link]('') # Preserve multiple spaces
continue
new_word = ''

69
for i, ch in enumerate(word):
ascii_val = ord(ch)
if i == 0:
1A
# Capitalize first letter if lowercase
if 97 <= ascii_val <= 122:
new_word += chr(ascii_val - 32)
07

else:
new_word += ch
else:
24

# Convert rest of letters to lowercase if uppercase


if 65 <= ascii_val <= 90:
new_word += chr(ascii_val + 32)
else:
new_word += ch
[Link](new_word)
print(' '.join(result))
# Read input
s = input()
capitalize_words(s)

VNR VJIET Powered by [Link]


Testcase 1
Input:
hello world python
Expected Output:
Hello World Python
Actual Output:
Hello World Python

53
Testcase 2
Input:

69
PROGRAMMING is FUN
Expected Output:
Programming Is Fun
1A
Actual Output:
Programming Is Fun
07
24

VNR VJIET Powered by [Link]


Exp: Remove Duplicates from List

Problem 26:
Remove Duplicates from List
Submitted Code:
def remove_duplicates(lst):
# Convert list to set to remove duplicates, then sort and return
unique_sorted = sorted(set(lst))
return unique_sorted
# Read input

53
n = int(input())
numbers = list(map(int, input().split()))
# Get unique sorted list

69
result = remove_duplicates(numbers)
# Print result
print(*result)
1A
Testcase 1
Input:
07

6
135371
Expected Output:
24

1357
Actual Output:
1357

Testcase 2
Input:
4
-2 -2 -2 -2
Expected Output:
-2
Actual Output:

VNR VJIET Powered by [Link]


-2

53
69
1A
07
24

VNR VJIET Powered by [Link]


Exp: Add Commas Between Characters

Problem 27:
Add Commas Between Characters
Submitted Code:
# Read input
s = input()
# Insert commas between characters
result = ','.join(s)
# Print the result

53
print(result)

Testcase 1

69
Input:
Apple
Expected Output:
1A
A,p,p,l,e
Actual Output:
A,p,p,l,e
07

Testcase 2
24

Input:
Hello123
Expected Output:
H,e,l,l,o,1,2,3
Actual Output:
H,e,l,l,o,1,2,3

VNR VJIET Powered by [Link]


Exp: Cumulative Product Calculator

Problem 28:
Cumulative Product Calculator
Submitted Code:
def cumulative_product(lst):
if not lst:
return "Empty list"
result = []
prod = 1

53
for num in lst:
prod *= num
[Link](prod)

69
return result
# Main program
n = int(input())
1A
if n == 0:
print("Empty list")
else:
07

numbers = list(map(int, input().split()))


result = cumulative_product(numbers)
print(*result)
24

Testcase 1
Input:
5
12345
Expected Output:
1 2 6 24 120
Actual Output:
1 2 6 24 120

VNR VJIET Powered by [Link]


Testcase 2
Input:
0
Expected Output:
Empty list
Actual Output:
Empty list

53
69
1A
07
24

VNR VJIET Powered by [Link]


Exp: List Reverse Function

Problem 29:
List Reverse Function
Submitted Code:
def reverse(lst):
if not lst:
print("Empty list")
else:
print(*lst[::-1])

53
# Main program
n = int(input())
if n == 0:

69
print("Empty list")
else:
numbers = list(map(int, input().split()))
1A
reverse(numbers)

Testcase 1
07

Input:
5
12345
24

Expected Output:
54321
Actual Output:
54321

Testcase 2
Input:
0
Expected Output:
Empty list
Actual Output:

VNR VJIET Powered by [Link]


Empty list

53
69
1A
07
24

VNR VJIET Powered by [Link]


Exp: Matrix Printer

Problem 30:
Matrix Printer
Submitted Code:
# Read dimensions
n, m = map(int, input().split())
# Read matrix elements
matrix = []
for _ in range(n):

53
row = list(map(int, input().split()))
[Link](row)
# Print the matrix

69
for row in matrix:
print(*row)
1A
Testcase 1
Input:
23
07

123
456
Expected Output:
24

123
456
Actual Output:
123
456

VNR VJIET Powered by [Link]


Testcase 2
Input:
32
78
9 10
11 12
Expected Output:
78

53
9 10
11 12
Actual Output:

69
78
9 10
11 12
1A
07
24

VNR VJIET Powered by [Link]


Exp: Square Matrix Addition

Problem 31:
Square Matrix Addition
Submitted Code:
# Read matrix size
n = int(input())
# Read first matrix
matrix1 = []
for _ in range(n):

53
row = list(map(int, input().split()))
[Link](row)
# Read second matrix

69
matrix2 = []
for _ in range(n):
row = list(map(int, input().split()))
1A
[Link](row)
# Add the two matrices
result = []
07

for i in range(n):
row = []
for j in range(n):
24

[Link](matrix1[i][j] + matrix2[i][j])
[Link](row)
# Print the resultant matrix
for row in result:
print(*row)

VNR VJIET Powered by [Link]


Testcase 1
Input:
2
12
34
56
78
Expected Output:

53
68
10 12
Actual Output:

69
68
10 12
1A
Testcase 2
Input:
07

3
123
456
24

789
987
654
321
Expected Output:
10 10 10
10 10 10
10 10 10
Actual Output:
10 10 10
10 10 10
10 10 10

VNR VJIET Powered by [Link]


Exp: Factorial Calculator using Recursion

Problem 32:
Factorial Calculator using Recursion
Submitted Code:
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)

53
# Main program
n = int(input())
print(factorial(n))

Testcase 1
Input: 69
1A
5
Expected Output:
120
07

Actual Output:
120
24

Testcase 2
Input:
0
Expected Output:
1
Actual Output:
1

VNR VJIET Powered by [Link]


Exp: Factorial Calculator using Recursion

Problem 33:
Factorial Calculator using Recursion
Submitted Code:
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)

53
# Main program
n = int(input())
print(factorial(n))

Testcase 1
Input: 69
1A
5
Expected Output:
120
07

Actual Output:
120
24

Testcase 2
Input:
0
Expected Output:
1
Actual Output:
1

VNR VJIET Powered by [Link]


Exp: Square Matrix Multiplication

Problem 34:
Square Matrix Multiplication
Submitted Code:
# Read matrix size
n = int(input())
# Read first matrix
matrix1 = []
for _ in range(n):

53
row = list(map(int, input().split()))
[Link](row)
# Read second matrix

69
matrix2 = []
for _ in range(n):
row = list(map(int, input().split()))
1A
[Link](row)
# Initialize result matrix with zeros
result = [[0] * n for _ in range(n)]
07

# Perform matrix multiplication


for i in range(n):
for j in range(n):
24

for k in range(n):
result[i][j] += matrix1[i][k] * matrix2[k][j]
# Print the resultant matrix
for row in result:
print(*row)

VNR VJIET Powered by [Link]


Testcase 1
Input:
2
12
34
56
78
Expected Output:

53
19 22
43 50
Actual Output:

69
19 22
43 50
1A
Testcase 2
Input:
07

3
123
456
24

789
987
654
321
Expected Output:
30 24 18
84 69 54
138 114 90
Actual Output:
30 24 18
84 69 54
138 114 90

VNR VJIET Powered by [Link]


Exp: Simple Calculator Using Functions

Problem 35:
Simple Calculator Using Functions
Submitted Code:
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):

53
return a * b
def divide(a, b):
if b == 0:

69
return "Error: Division by zero"
return a / b
# Main program
1A
num1 = float(input())
operator = input().strip()
num2 = float(input())
07

if operator == '+':
result = add(num1, num2)
elif operator == '-':
24

result = subtract(num1, num2)


elif operator == '*':
result = multiply(num1, num2)
elif operator == '/':
result = divide(num1, num2)
else:
result = "Invalid operator"
if isinstance(result, str):
print(result)
else:
print(f"{result:.2f}")

VNR VJIET Powered by [Link]


Testcase 1
Input:
10.5
+
5.5
Expected Output:
16.00
Actual Output:

53
16.00

69
Testcase 2
Input:
20.0
1A
/
0.0
Expected Output:
07

Error: Division by zero


Actual Output:
Error: Division by zero
24

VNR VJIET Powered by [Link]

You might also like