Skip to content

Latest commit

 

History

History
67 lines (57 loc) · 2.24 KB

README.md

File metadata and controls

67 lines (57 loc) · 2.24 KB

Extended Set

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.

Classes

  1. SetX

Sources

  1. Python Documentation
  2. Book of Proof by Richard Hammack, chapter on sets - mathematical structures

Operations on Set

  1. len(Set)
  2. element in Set
  3. x not in Set
  4. isdisjoint
  5. issubset
  6. issuperset
  7. union
  8. difference
  9. symmetric_difference
  10. copy
  11. add
  12. remove
  13. pop
  14. discard
  15. clear
  16. intersection

Operations on SetX

  1. cardinality
  2. isempty
  3. cartesian_product
  4. power_set
  5. complement
  6. iselement

Definitions of terms & operations on SetX

  1. 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.
    
  2. 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.
    
  3. Non-empty(null) sets : This is a set that has at least 1 element. This set is not empty or null.

  4. Cartesian product : Given the sets, A and B as non-empty sets , 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)}
    
  5. Power set : Given a non-empty set A, the power set of A, which is another set, denoted by P(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}}
    

Know that

  1. The sweet terms are all from Mr. Richard Hammack book, book of proof
  2. I will use informal language to express certain points
  3. cardinality is the same as len(set)
  4. isempty checks if {}
  5. complement, intersection, difference and disjoint has something to do with each other.