A Python Trinket: Basic Set Operations

Here are a few lines of Python code I wrote to demonstrate how the basics of sets work in Python. Note that these are the same sets A and B that appeared on Exam #2!

So far I’ve only put in code to compute and print $A \cup B$. Take a minute to look at this link for a primer on the other basic set operations, and then add a couple lines of code to compute $A \cap B$, $A-B$, $B-A$ and $A \oplus B$.

Leave a Reply

Your email address will not be published. Required fields are marked *