--- id: python-sets title: "Python Sets" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["파이썬 μ…‹"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["python", "programming", "w3schools", "sets"] raw_sources: ["https://www.w3schools.com/python/python_sets.asp"] applied_in: [] github_commit: "" --- # [[Python Sets]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) A set is Python's unordered, unindexed, no-duplicates collection β€” and its duplicate detection treats True/1 as the same value, and False/0 as the same value, since equality (not just type) determines duplication. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Set** β€” one of Python's 4 built-in collection types; unordered, "unchangeable"* (items can't be modified, but can be added/removed), unindexed, written with `{}`. [S1] - **Unordered** β€” items have no defined order and cannot be accessed by index or key. [S1] - **No duplicates** β€” sets silently drop duplicate values on creation. [S1] - **`True`/`1` and `False`/`0` collapse** β€” these pairs are treated as the same value for duplicate purposes. [S1] - **`set()` constructor** β€” alternative creation syntax. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Value-equality-based dedup, not type-based** β€” `{True, 1, 2}` collapses to `{True, 2}` (or `{1, 2}`) because `True == 1` in Python, illustrating that set uniqueness follows `==`, not `type()`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Basic creation: `thisset = {"apple", "banana", "cherry"}`. [S1] - Duplicate dropped: `thisset = {"apple", "banana", "cherry", "apple"}` β†’ duplicate "apple" ignored. [S1] - True/1 collapse: `thisset = {"apple", "banana", "cherry", True, 1, 2}`. [S1] - Constructor: `thisset = set(("apple", "banana", "cherry"))`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. "unchangeable"μ΄λΌλŠ” ν‘œν˜„ μžμ²΄κ°€ 각주(*)둜 "μ œκ±°Β·μΆ”κ°€λŠ” κ°€λŠ₯ν•˜λ‹€"κ³  완화됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” Set μ—°μ‚°(union/intersection/difference)은 이후 Join Sets μ±•ν„°μ—μ„œ 본격적으둜 닀뀄진닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) True/1 duplicate collapse (Python): ```python thisset = {"apple", "banana", "cherry", True, 1, 2} print(thisset) # True and 1 collapse to one value ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[Python Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[Python Lists]], [[Python Frozenset]], [[Python Sets Join]] - **μ°Έμ‘° λ§₯락:** 4λŒ€ μ»¬λ ‰μ…˜ νƒ€μž… 쀑 ν•˜λ‚˜ β€” κ³ μœ κ°’ μ§‘ν•© 연산이 ν•„μš”ν•  λ•Œ μ‚¬μš©. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” Python Sets β€” https://www.w3schools.com/python/python_sets.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "Python Sets" page (Astra wiki-curation, P-Reinforce v3.1 format).