This is an extension of the set class with additional methods for set cardinality, cartesian product, power set, etc. As an extension for the set class it is meant to work fine as a set.
- SetX
- Python Documentation
- Book of Proof by Richard Hammack, chapter on sets - mathematical structures
len(Set)- element
inSet - x
notinSet isdisjointissubsetissupersetuniondifferencesymmetric_differencecopyaddremovepopdiscardclearintersection
cardinalityisemptycartesian_productpower_setcomplementiselement
-
Cardinality: This is the size (magnitude) of a set. It is the number of elements in the set.Eg: Given a set A = {1,2,3,4,5}, set A has a cardility of 5. This because the number of elements in set A is 5. -
Empty(Null) Set: This is a set of size zero. This set has no elements.Eg: Given a set E = {}, set E is an empty set or a null set. -
Non-empty(null) sets: This is a set that has at least 1 element. This set is not empty or null. -
Cartesian product: Given the sets, A and B asnon-emptysets , denoted by(A x B)and defined as(A x B) = {(a, b): a in A, b in B}.Eg: Given that set A = {1, 2, 3} and set B = {a, b} The cartesian product of A and B, (A x B) = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)} -
Power set: Given anon-emptyset A, thepower setof A, which is another set, denoted byP(A)and defined to be the set of all subsets of A.Eg: Given set A = {1,2,3} The Power set of A, P(A) = {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
- The sweet terms are all from Mr. Richard Hammack book, book of proof
- I will use informal language to express certain points
cardinalityis the same aslen(set)isemptychecks if{}complement,intersection,differenceanddisjointhas something to do with each other.