[Introduction à Udemy Python3 + Application] 30. Comment utiliser l'ensemble

** * Cet article provient d'Udemy "[Introduction à Python3 enseignée par des ingénieurs actifs de la Silicon Valley + application + style de code de style américain de la Silicon Valley](https://www.udemy.com/course/python-beginner/" Introduction à Python3 enseignée par des ingénieurs actifs de la Silicon Valley + application + Style de code de style de la Silicon Valley américaine ")" C'est une note de classe pour moi après avoir suivi le cours. Il est ouvert au public avec la permission de l'instructeur Jun Sakai. ** **

■ Où utiliser la réunion

◆ Exemple 1

mutual_friend


my_friends = {'A', 'C', 'D'}
your_friends = {'B', 'D', 'E', 'F'}

# Who is our mutual friend?
print(my_friends & your_friends)

result


{'D'}

En affichant my_friends et your_friends, J'ai pu trouver un ami commun.

◆ Exemple 2

fruits_basket


basket = ['apple', 'lemon', 'banana', 'apple', 'apple', 'banana']

# change list to set
kind = set(basket)

print(kind)

result


{'apple', 'banana', 'lemon'}

Après avoir mis correctement les fruits dans le panier, je veux vérifier le type de fruits qu'il contient. panier est défini comme un type de liste, Si vous le convertissez en un type collectif, les doublons seront combinés en un seul.

Recommended Posts

[Introduction à Udemy Python3 + Application] 30. Comment utiliser l'ensemble
[Introduction à Udemy Python3 + Application] 27. Comment utiliser le dictionnaire
[Introduction à l'application Udemy Python3 +] 23. Comment utiliser Tapuru
[Introduction à Udemy Python3 + Application] 29. Méthode Set
[Introduction à l'application Udemy Python3 +] 36. Utilisation de In et Not
[Introduction à Udemy Python3 + Application] 62. Définir la notation d'inclusion
[Présentation de l'application Udemy Python3 +] 31. Commentaire
[Présentation de l'application Udemy Python3 +] 57. Décorateur
[Présentation de l'application Udemy Python3 +] 56. Clôture
[Introduction à l'application Udemy Python3 +] Résumé
[Introduction à Udemy Python3 + Application] 18. Méthode List
[Introduction à Udemy Python3 + Application] 63. Notation d'inclusion du générateur
[Introduction à l'application Udemy Python3 +] 28. Type collectif
[Introduction à Python] Comment utiliser la classe en Python?
[Introduction à Udemy Python3 + Application] 25. Méthode de type dictionnaire
[Introduction à Udemy Python3 + Application] 13. Méthode de caractères
[Introduction à l'application Udemy Python3 +] 55. Fonctions intégrées
[Introduction à l'application Udemy Python3 +] 48. Définition des fonctions
[Introduction à l'application Udemy Python3 +] 21. Type Taple
[Introduction à l'application Udemy Python3 +] 45. fonction enumerate
[Introduction à l'application Udemy Python3 +] 41. fonction d'entrée
[Introduction à l'application Udemy Python3 +] 17. Opération de liste
[Introduction à l'application Udemy Python3 +] 65. Gestion des exceptions
[Introduction à l'application Udemy Python3 +] 11. Chaîne de caractères
[Introduction à l'application Udemy Python3 +] 44. fonction range
[Introduction à l'application Udemy Python3 +] 46. fonction zip
[Introduction à l'application Udemy Python3 +] 24. Type de dictionnaire
[Introduction à Udemy Python3 + Application] 8. Déclaration de variable
[Introduction à l'application Udemy Python3 +] 16. Type de liste
[Introduction à Udemy Python3 + Application] 61. Notation d'inclusion de dictionnaire
[Introduction à l'application Udemy Python3 +] 22. Déballage de taples
[Introduction à Python] Comment utiliser l'opérateur in dans l'instruction for?
[Introduction à Python] Comment utiliser l'opérateur booléen (et ・ ou ・ non)
Comment utiliser la bibliothèque C en Python
[Introduction à Udemy Python3 + Application] 60. Notation d'inclusion de liste
[Introduction à Udemy Python3 + Application] 19. Copie de la liste
[Introduction à Udemy Python3 + Application] 38. Lors du jugement Aucun
[Introduction à l'application Udemy Python3 +] 40. Instruction while else
[Introduction à l'application Udemy Python3 +] 43. instruction for else
[Algorithm x Python] Comment utiliser la liste
[Introduction à l'application Udemy Python3 +] 9. Tout d'abord, imprimez avec print
[Introduction à l'application Udemy Python3 +] 54. Qu'est-ce que Docstrings?
[Introduction à Udemy Python3 + Application] 14. Substitution de caractères 15.f-strings
python3: Comment utiliser la bouteille (2)
Comment utiliser le générateur
[Python] Comment utiliser la liste 1
Comment utiliser Python Argparse
Python: comment utiliser pydub
[Python] Comment utiliser input ()
Comment utiliser le décorateur
[Introduction] Comment utiliser open3d
Comment utiliser Python lambda
[Python] Comment utiliser virtualenv
python3: Comment utiliser la bouteille (3)
python3: Comment utiliser la bouteille
Comment utiliser les octets Python
[Introduction à l'application Udemy Python3 +] 35. Opérateurs de comparaison et opérateurs logiques
[Introduction à Python] Comment utiliser l'instruction while (traitement répétitif)
[Introduction à l'application Udemy Python3 +] 66. Création de votre propre exception
Comment utiliser Raspeye Relay Module Python
[Introduction à Udemy Python3 + Application] 53. Dictionnaire des arguments de mots-clés