Practical
Practical
-CERTIFICATE--CERTIFICATE- 2
PROGRAM 10
PROGRAM 9
#Write a program to Pop an
Element from a Dictionary
Source Code:
my_dict = {'name': 'John', 'age': 25, 'city':
'New York'}
popped_value = my_dict.pop('age')
print("Popped Value:", popped_value)
print("Updated Dictionary:", my_dict)
Output:
Popped Value: 25
Updated Dictionary: {'name': 'John', 'city':
'New York'}
-CERTIFICATE--CERTIFICATE- 4
PROGRAM 8
#Write a program to clear
all elements from a
dictionary
Source Code:
my_dict = {'name': 'John', 'age': 25,
'city': 'New York'}
my_dict.clear()
print("Cleared Dictionary:",
my_dict)
Output:
Cleared Dictionary: {}
-CERTIFICATE--CERTIFICATE- 5
PROGRAM 7
#Write a program to merge
two dictionaries
Source Code:
dict1 = {'name': 'Alice', 'age': 30}
dict2 = {'city': 'London', 'job':
'Engineer'}
dict1.update(dict2)
print("Merged Dictionary:", dict1)
Output:
Merged Dictionary: {'name': 'Alice',
'age': 30, 'city': 'London', 'job':
'Engineer'}
-CERTIFICATE--CERTIFICATE- 6
PROGRAM 6
# Write a program to check
if an item exists in a tuple
Source Code:
my_tuple = (10, 20, 30, 40, 50) item_to_check
= 30
if item_to_check in my_tuple:
print(f"{item_to_check} exists in the tuple.")
else:
print(f"{item_to_check} does not exist in the
tuple.")
Output:
30 exists in the tuple.
-CERTIFICATE--CERTIFICATE- 7
PROGRAM 5
# write a program to find
the length of a tuple
Source Code:
my_tuple = (1, 2, 3, 4, 5)
length = len(my_tuple)
print("Length of the tuple:", length)
Output:
Length of the tuple: 5
-CERTIFICATE--CERTIFICATE- 8
PROGRAM 4
#Write a program to input a
tuple and check if it contains
the all elements as same.
Source Code:
tup = eval(input("Enter a tuple: "))
In = len(tup)
num=tup.count(tup[0])
if num == 1n:
print("Tuple contains all the same elements.")
else:
print("Tuple contains different elements.")
Output:
Enter a tuple: 23,23,23,23
-CERTIFICATE--CERTIFICATE- 9
PROGRAM 3
#Write a program to print
the index of the minimum
element in a tuple.
Source code:
tup = eval(input("Enter a tuple : "))
mn = min(tup)
print("Minimum element", mn,\
"is at index", tup.index(mn))
Output:
Enter a tuple 23, 22, 11, 9, 10, 15
Minimum element 9 is at index 3
-CERTIFICATE--CERTIFICATE- 10
PROGRAM 2
PROGRAM 1
#Write a program to create a tuple
with a single input value.
Source code:
t1 = eval(input("Enter input for tuple: "))
print("Created tuple is:", t1)
Output:
Enter input for tuple: 67,
Created tuple is: (67,)
2025/2/10 21:21
-CERTIFICATE--CERTIFICATE- 12
-CERTIFICATE-
This is to certify that
Chetna Sharma of class
XI-A has completed her
Practical in Session
2024-25 as per the
prescribed practical
syllabus under the
guidance of Asha Sharma
Ma’am and submitted for
the practical
examination held on 17
Feb 2025
-CERTIFICATE--CERTIFICATE- 13
Yours Truly
Chetna Sharma
-CERTIFICATE--CERTIFICATE- 14
Computer Science
Practical-II
CHETNA SHARMA
XI-A