메뉴 여닫기
개인 메뉴 토글
로그인하지 않음
만약 지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.

튜플 리스트 딕셔너리 차이점,특징,사용예시

데브카페
Devcafe (토론 | 기여)님의 2024년 10월 21일 (월) 20:36 판 (새 문서: === 튜플 딕셔너리 리스트 차이점 ,특징 === {| class="wikitable" |+ List, Dictionary, Tuple 비교 ! Feature !! List !! Dictionary !! Tuple |- ! **Definition** | Ordered, mutable sequence of items | Unordered, mutable collection of key-value pairs | Ordered, immutable sequence of items |- ! **사용 문법** | `[1, 2, 3]` | `{'key1': 'value1', 'key2': 'value2'}` | `(1, 2, 3)` |- ! **Mutable?** | Yes | Yes | No |- ! **Indexed Access** | Yes (by index) | Yes (by key) |...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

튜플 딕셔너리 리스트 차이점 ,특징

List, Dictionary, Tuple 비교
Feature List Dictionary Tuple
**Definition** Unordered, mutable collection of key-value pairs | Ordered, immutable sequence of items
**사용 문법** `{'key1': 'value1', 'key2': 'value2'}` | `(1, 2, 3)`
**Mutable?** Yes | No
**Indexed Access** Yes (by key) | Yes (by index)
**증복허용 여부 ** No (keys must be unique) | Yes
** 사용예시 ** Storing key-value pairs for fast lookup | Storing fixed collections that should not change
**언제 사용 하나?** When you need to associate values with unique keys | When you need an ordered and immutable collection
**Example Code**
my_list = [1, 2, 3]
print(my_list[0])  # Output: 1
my_dict = {'name': 'Alice', 'age': 25}
print(my_dict['name'])  # Output: Alice
my_tuple = (1, 2, 3)
print(my_tuple[1])  # Output: 2

Comments