diff --git a/curriculum/challenges/english/blocks/lecture-working-with-dictionaries-and-sets/683ec8fd8b21827317388a45.md b/curriculum/challenges/english/blocks/lecture-working-with-dictionaries-and-sets/683ec8fd8b21827317388a45.md index 52027da7387..a1fa492a6ab 100644 --- a/curriculum/challenges/english/blocks/lecture-working-with-dictionaries-and-sets/683ec8fd8b21827317388a45.md +++ b/curriculum/challenges/english/blocks/lecture-working-with-dictionaries-and-sets/683ec8fd8b21827317388a45.md @@ -103,7 +103,7 @@ The difference operator `-` returns a new set with the elements of the first set my_set - your_set # {1, 5} ``` -The symmetric difference operator `^` returns a new set with the elements that are either on the first or the second set, but not both. In this case, 1 and 5 are in `my_set` but not in `your_set`, so they are included. And the number 6 is in `your_set` but not in `my_set`, so it's included as well: +The symmetric difference operator `^` returns a new set with the elements that are either in the first or the second set, but not both. In this case, 1 and 5 are in `my_set` but not in `your_set`, so they are included. And the number 6 is in `your_set` but not in `my_set`, so it's included as well: ```python my_set ^ your_set # {1, 5, 6} diff --git a/curriculum/challenges/english/blocks/quiz-dictionaries-and-sets/67f412ac59601c4151b763da.md b/curriculum/challenges/english/blocks/quiz-dictionaries-and-sets/67f412ac59601c4151b763da.md index c9ffba57a8b..c549a1f2f50 100644 --- a/curriculum/challenges/english/blocks/quiz-dictionaries-and-sets/67f412ac59601c4151b763da.md +++ b/curriculum/challenges/english/blocks/quiz-dictionaries-and-sets/67f412ac59601c4151b763da.md @@ -466,7 +466,7 @@ It returns a new set with the elements of the first set that are not in the othe #### --answer-- -It returns a new set with the elements that are either on the first or the second set, but not both. +It returns a new set with the elements that are either in the first or the second set, but not both. ### --question-- diff --git a/curriculum/challenges/english/blocks/review-dictionaries-and-sets/67f39babe1e2ec1fb6eea32a.md b/curriculum/challenges/english/blocks/review-dictionaries-and-sets/67f39babe1e2ec1fb6eea32a.md index c73dfeb8812..c35d7f7b184 100644 --- a/curriculum/challenges/english/blocks/review-dictionaries-and-sets/67f39babe1e2ec1fb6eea32a.md +++ b/curriculum/challenges/english/blocks/review-dictionaries-and-sets/67f39babe1e2ec1fb6eea32a.md @@ -241,7 +241,7 @@ my_set.clear() - **`issubset()` and `issuperset()` Methods**: The `issubset()` and the `issuperset()` methods check if a set is a subset or superset of another set, respectively. ```python -my_set = {1, 2, 3, 4, 5} +my_set = {1, 2, 3, 4, 5} your_set = {2, 3, 4, 5} print(your_set.issubset(my_set)) # True @@ -251,37 +251,52 @@ print(my_set.issuperset(your_set)) # True - **`isdisjoint()` Method**: The `isdisjoint()` method checks if two sets are disjoint, if they don't have elements in common. ```python -print(my_set.isdisjoint(your_set)) # False +my_set = {1, 2, 3} +your_set = {4, 5, 6} + +print(my_set.isdisjoint(your_set)) # True ``` - **Union Operator (`|`)**: The union operator `|` returns a new set with all the elements from both sets. ```python +my_set = {1, 2, 3} +your_set = {4, 5, 6} + my_set | your_set # {1, 2, 3, 4, 5, 6} ``` - **Intersection Operator (`&`)**: The intersection operator `&` returns a new set with only the elements that the sets have in common. ```python +my_set = {1, 2, 3, 4, 5} +your_set = {2, 3, 4, 6} + my_set & your_set # {2, 3, 4} ``` - **Difference Operator (`-`)**: The difference operator `-` returns a new set with the elements of the first set that are not in the other sets. ```python +my_set = {1, 2, 3, 4, 5} +your_set = {2, 3, 4, 6} + my_set - your_set # {1, 5} ``` -- **Symmetric Difference Operator (`^`)**: The symmetric difference operator `^` returns a new set with the elements that are either on the first or the second set, but not both. +- **Symmetric Difference Operator (`^`)**: The symmetric difference operator `^` returns a new set with the elements that are either in the first or the second set, but not both. ```python +my_set = {1, 2, 3, 4, 5} +your_set = {2, 3, 4, 6} + my_set ^ your_set # {1, 5, 6} ``` - **`in` Operator**: You can check if an element is in a set or not with the `in` operator. ```python -print(5 in my_set) +print(5 in my_set) # True ``` ## Python Standard Library diff --git a/curriculum/challenges/english/blocks/review-python/67f39e391c9b373069def02c.md b/curriculum/challenges/english/blocks/review-python/67f39e391c9b373069def02c.md index bb89cd3e5cd..41f99d6e089 100644 --- a/curriculum/challenges/english/blocks/review-python/67f39e391c9b373069def02c.md +++ b/curriculum/challenges/english/blocks/review-python/67f39e391c9b373069def02c.md @@ -1807,7 +1807,7 @@ my_set.clear() - **`issubset()` and `issuperset()` Methods**: The `issubset()` and the `issuperset()` methods check if a set is a subset or superset of another set, respectively. ```python -my_set = {1, 2, 3, 4, 5} +my_set = {1, 2, 3, 4, 5} your_set = {2, 3, 4, 5} print(your_set.issubset(my_set)) # True @@ -1817,30 +1817,45 @@ print(my_set.issuperset(your_set)) # True - **`isdisjoint()` Method**: The `isdisjoint()` method checks if two sets are disjoint, if they don't have elements in common. ```python -print(my_set.isdisjoint(your_set)) # False +my_set = {1, 2, 3} +your_set = {4, 5, 6} + +print(my_set.isdisjoint(your_set)) # True ``` - **Union Operator (`|`)**: The union operator `|` returns a new set with all the elements from both sets. ```python +my_set = {1, 2, 3} +your_set = {4, 5, 6} + my_set | your_set # {1, 2, 3, 4, 5, 6} ``` - **Intersection Operator (`&`)**: The intersection operator `&` returns a new set with only the elements that the sets have in common. ```python +my_set = {1, 2, 3, 4, 5} +your_set = {2, 3, 4, 6} + my_set & your_set # {2, 3, 4} ``` - **Difference Operator (`-`)**: The difference operator `-` returns a new set with the elements of the first set that are not in the other sets. ```python +my_set = {1, 2, 3, 4, 5} +your_set = {2, 3, 4, 6} + my_set - your_set # {1, 5} ``` -- **Symmetric Difference Operator (`^`)**: The symmetric difference operator `^` returns a new set with the elements that are either on the first or the second set, but not both. +- **Symmetric Difference Operator (`^`)**: The symmetric difference operator `^` returns a new set with the elements that are either in the first or the second set, but not both. ```python +my_set = {1, 2, 3, 4, 5} +your_set = {2, 3, 4, 6} + my_set ^ your_set # {1, 5, 6} ```