fix(curriculum): correct symmetric difference wording and examples (#64512)

Co-authored-by: Ilenia M <nethleen@gmail.com>
Co-authored-by: Dario <105294544+Dario-DC@users.noreply.github.com>
This commit is contained in:
Geetansh Goyal
2025-12-18 10:45:31 +01:00
committed by GitHub
co-authored by Ilenia M Dario
parent 75f3021c77
commit 1a61e47696
4 changed files with 39 additions and 9 deletions
@@ -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}
@@ -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--
@@ -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
@@ -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}
```