Set Operations
noun
say it: “SET op-er-AY-shunz” /sɛt ˌɑpəˈreɪʃənz/
Ways to combine two sets: | gives everything in either, & gives what they share, and - gives what's in the first but not the second.
What are set operations?
Set operations combine sets: | everything from both, & only what they share, - what's in the first but not the second.
monday = {"Ana", "Ben", "Cai"}
tuesday = {"Ben", "Dee"}
print(monday & tuesday) # {'Ben'}: came both days
print(monday - tuesday) # {'Ana', 'Cai'}
In a sentence
- “With set operations, the shop found which customers bought last month but not this month.”
- “Set operations showed that only Ben came on both Monday and Tuesday.”
Level: Journeyman · More Python terms at this level
Updated