Set Membership & Relationship11:03 with AJ Tran
Membership testing is a distinguishing feature of sets. Testing for membership means asking if an element is present in a set. Sets can have relationships with each other based on their common membership.
These operations return a boolean value.
Testing for Membership
x in set True if set contains element.
x not in set True if set does not contain element.
Testing for Equality
== "equal to" - True if two sets are equal length and contain the exact same members
!= "not equal to" - Opposite of "equal to"
Testing for Relationship
isdisjoint() - True if two sets have a null intersection (ie. no members in common).
<= - True if another set contains this set.
>= True if this set contains another set.
An empty set is both a disjointed set and a subset of all sets.
A set is both a subset and a superset of itself.
string module has constants that are good for working with strings. Python has a lot of built-in modules that are very useful to know. You may be familiar with some already, like
statistics. These modules are part of the Python Standard Library. Modules are important to know about because it's code that other people wrote to handle common patterns and problems in programming. And you get these for free just by having Python installed on your computer! You can view an index of the built-in modules in the Python documentation
You need to sign up for Treehouse in order to download course files.Sign up