Psst! Check what courses we have in our offer, and get them all here to save $727. Tick-tock—this deal ends on 3/21.
Set basics
Relationships between sets
15. Summary


All right, it's time to wrap things up. First, a summary of what we've learned:

  1. Basic set operations are given below with comments:

    # define a non-empty set
    prime_numbers = {2, 3, 5, 7}
    # define an empty set
    prime_numbers = set()
    # add an element
    # remove an element
    # remove all elements
    # iterate over a set
    for number in prime_numbers: ...
    # check if an element is in the set
    if number in prime_numbers: ...
  2. The following functions are used to create a new set from two sets: intersection(), union(), difference(), and symmetric_difference().
  3. To specify the relationship between two sets, we can use issubset() and issuperset().

Are you ready for a short quiz?


Click Next exercise to continue.