|
Set operations & comparisons
Combine sets and compare their elements. Learning objectives
11.2.1.3 apply union, intersection, subtraction, and symmetric difference operations on sets 11.2.1.4 compare sets 1. Operations on two setsUse these sets in the four examples. In the original pictures, Set1 is A and Set2 is B.
UnionAt least one of the two sets.
Result: IntersectionBoth sets.
Result: Difference / subtractionIn A but not in B.
Result: Symmetric differenceExactly one set; exclude shared elements.
Result: The operations create a new result set; A and B remain unchanged. Result elements are arranged for readability here. Python may display them in a different order. Use
print(result) to display a set.Direction matters:
2. Compare setsCompare the elements and containment, rather than sizes alone.
A smaller set need not be a subset. For
X = {1} and Y = {2, 3}, all three expressions X < Y, X > Y and X == Y are False. The empty set is a subset of every set and a proper subset of every non-empty set.3. Set laboratoryEnter integers separated by spaces or commas. Use a blank field or Shading marks the operation regions, including empty regions. Circle sizes do not represent counts. Union
A | B = {1, 2, 4, 5, 6, 8}
A.union(B)
4. Exercises8 exercises in total: 3 LearningApps activities and 5 checked tasks. Set answers may use any element order; type Checked tasks: 0 / 5
Progress is saved in this browser. LearningApps results are separate. Clear answers to the five checked tasks? Reference: Python documentation: set. | ||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||
| Просмотров: 8 | | | ||||||||||||||||||||||||||||||||||||
| Всего комментариев: 0 | |