0% found this document useful (0 votes)
5 views2 pages

Method 1

The document provides a list of set methods in Python along with their shortcuts and descriptions. Each method is designed to perform specific operations on sets, such as adding, removing, or comparing elements. The methods include add, clear, copy, difference, intersection, and others, each with a defined functionality.

Uploaded by

sahiljamwal2720
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)
5 views2 pages

Method 1

The document provides a list of set methods in Python along with their shortcuts and descriptions. Each method is designed to perform specific operations on sets, such as adding, removing, or comparing elements. The methods include add, clear, copy, difference, intersection, and others, each with a defined functionality.

Uploaded by

sahiljamwal2720
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
You are on page 1/ 2

Method Shortcut Description

add() Adds an element to the set

clear() Removes all the elements from the set

copy() Returns a copy of the set

difference() - Returns a set containing the difference between two or more set

difference_update() -= Removes the items in this set that are also included in another,

specified set

discard() Remove the specified item

intersection() & Returns a set, that is the intersection of two other sets

intersection_update() &= Removes the items in this set that are not present in other,

specified set(s)

isdisjoint() Returns whether two sets have a intersection or not

issubset() <= Returns whether another set contains this set or not

< Returns whether all items in this set is present in other,

specified set(s)

issuperset() >= Returns whether this set contains another set or not

> Returns whether all items in other, specified set(s) is

present in this set

pop() Removes an element from the set

remove() Removes the specified element

symmetric_difference() ^ Returns a set with the symmetric differences of two sets


symmetric_difference_update() ^= Inserts the symmetric differences from this set and another

union() | Return a set containing the union of sets

update() |= Update the set with the union of this set and others

You might also like