Practical- 10
LLO: Write a python program to manipulate the set.
Program: Write python program to perform following operations on the Set;
Create set, Access Set, Update Set, Delete Set:
My_set = {1, 2, 3, 4, 5}
Print(“Set:”, my_set)
For item in my_set:
Print(“Accessed item:”, item)
My_set.add(6)
Print(“Updated Set (after adding 6):”, my_set)
My_set.remove(3)
Print(“Updated Set (after removing 3):”, my_set)
Del my_set
O/P:
PRQs: -
A3.
My_set = {1, 2, 3, 4, 5}
My_set.add(6)
My_set.add(7)
Print(“Set after adding members:”, my_set)
My_set.remove(4)
Print(“Set after removing 4:”, my_set)
O/P:
A4.
My_set = {10, 20, 5, 30, 15}
Print(“Maximum value:”, max(my_set))
Print(“Minimum value:”, min(my_set))
O/P:
A5.
My_set = {10, 20, 30, 40, 50}
Count = 0
For item in my_set:
Count += 1
Print(“Length of the set:”, count)
O/P: