sets and maps listing continued determines if this set is subset of setb def issubsetofselfsetb )for element in self if element not in setb return false return true creates new set from the union of this set and setb def unionselfsetb )newset set(newset _theelements extendself _theelements for element in setb if element not in self newset _theelements appendelement return newset creates new set from the intersectionself set and setb def intersetselfsetb )creates new set from the differenceself set and setb def differenceselfsetb )returns an iterator for traversing the list of items def __iter__self )return _setiteratorself _theelements adding elements as indicated earlierwe must ensure that duplicate values are not added to the set since the list structure does not handle this for us when implementing the add methodshown in lines - we must first determine if the supplied element is already in the list or not if the element is not duplicatewe can simply append the value to the end of the listif the element is duplicatewe do nothing the reason for this is that the definition of the add(operation indicates no action is taken when an attempt is made to add duplicate value this is known as noopwhich is short for no operation and indicates no action is taken noops are appropriate in some caseswhich will be stated implicitly in the definition of an abstract data type by indicating no action is to be taken when the precondition fails as we did with the add(operation comparing two sets for the operations that require second set as an argumentwe can use the operations of the set adt itself to access and manipulate the data of the second set consider the "equalsoperationimplemented in lines - of listing which determines if both sets contain the exact same elements we first check to make