June 2017
Beginner
352 pages
8h 39m
English
Perhaps the most useful aspect of the set type is the group of powerful set algebra operations which are provided. These allow us to easily compute set unions, set differences, and set intersections, and to evaluate whether two sets have subset, superset, or disjoint relations.
To demonstrate these methods, we'll construct some sets of people according to various phenotypes:
>>> blue_eyes = {'Olivia', 'Harry', 'Lily', 'Jack', 'Amelia'}>>> blond_hair = {'Harry', 'Jack', 'Amelia', 'Mia', 'Joshua'}>>> smell_hcn = {'Harry', 'Amelia'}>>> taste_ptc = {'Harry', 'Lily', 'Amelia', 'Lola'}>>> o_blood = {'Mia', 'Joshua', 'Lily', 'Olivia'}>>> b_blood = {'Amelia', 'Jack'}>>> a_blood = {'Harry'}>>> ab_blood = {'Joshua', 'Lola'}Read now
Unlock full access