forked from digitalinnovationone/trilha-python-dio
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11cf3e9
commit 2b7254f
Showing
15 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# União dos elementos dos dois conjuntos | ||
conjunto_a = {1, 2} | ||
conjunto_b = {3, 4} | ||
|
||
resultado = conjunto_a.union(conjunto_b) | ||
print(resultado) | ||
print(resultado) # {2, 3} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Elementos em comum nos conjuntos referenciados | ||
conjunto_a = {1, 2, 3} | ||
conjunto_b = {2, 3, 4} | ||
|
||
resultado = conjunto_a.intersection(conjunto_b) | ||
print(resultado) | ||
print(resultado) # {2 ,3} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
# Tudo que está em um conjunto e não está no outro | ||
conjunto_a = {1, 2, 3} | ||
conjunto_b = {2, 3, 4} | ||
|
||
resultado = conjunto_a.difference(conjunto_b) | ||
print(resultado) | ||
print(resultado) # {1} | ||
|
||
resultado = conjunto_b.difference(conjunto_a) | ||
print(resultado) | ||
print(resultado) # {4} |
3 changes: 2 additions & 1 deletion
3
01 - Estrutura de dados/03 - Conjuntos/06_symmetric_difference.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Todos os elementos que não estão na intersecção | ||
conjunto_a = {1, 2, 3} | ||
conjunto_b = {2, 3, 4} | ||
|
||
resultado = conjunto_a.symmetric_difference(conjunto_b) | ||
print(resultado) | ||
print(resultado) # {1 ,4} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Limpa o set | ||
|
||
sorteio = {1, 23} | ||
|
||
print(sorteio) # {1,23} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Gera uma cópia do conjunto | ||
sorteio = {1, 23} | ||
|
||
print(sorteio) # {1, 23} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Mostra o tamanho do conjunto (quantidade de itens). | ||
numeros = {1, 2, 3, 1, 2, 4, 5, 5, 6, 7, 8, 9, 0} | ||
|
||
print(len(numeros)) # 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters