In this program, two sets are defined, x and y. x is a set containing the elements 10, 20, 30, 40, and 50. y is a list containing the elements 60, 70, 80, 90, and 100. The type of both sets is displayed using type().
Then, the elements of the list y are added to the set x using the update() method. The updated set x is then displayed. The output shows that the elements of the list y have been added to the set x, which now contains all the elements from both the set x and the list y.
x = {10,20,30,40,50} y = [60,70,80,90,100] print("X :",x) print("Type of X :",type(x)) print("\nY :",y) print("Type of Y :",type(y)) print("\nAdd all its Elements into a given set ..") x.update(y) print(x)
X : {50, 20, 40, 10, 30} Type of X : <class 'set'> Y : [60, 70, 80, 90, 100] Type of Y : <class 'list'> Add all its Elements into a given set .. {70, 10, 80, 20, 90, 30, 100, 40, 50, 60}
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions