> For the complete documentation index, see [llms.txt](https://mikkicoding.mikkipastel.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mikkicoding.mikkipastel.com/python-for-beginner/10-python-data-structure.md).

# Data structure

### Tuple

เราสามารถเก็บข้อมูล data type ใดก็ได้ ในตัวแปร tuple

```python
t = 12345, 54321, 'hello!'
```

การ update ค่าใน tuple : `t[0] = 0`

เราสามารถนำ tuple นำมาบวกกันได้ด้วยนะ : `t3 = t1 + t2`

การลบค่าทั้งหมดใน tuple : `del t`

### Set

* union => `a | b`
* intersection => `a & b`
* difference => `a-b`, `b-a`
* symmetric difference => `a ^ b`

### Dictionary

การแสดงผลค่า key และ value ของสมาชิกแต่ละตัวใน dict

```python
for key, val in num.items():
 print (key, val)
```

การเรียงค่า key ของ dict โดย output จะเป็น list `sorted(num)`

การเรียงค่า key และ value ของ dict โดย output จะเป็น list เช่นกัน `sorted(num.value)`

สำหรับการ sort by key และแสดง member ทั้งหมดใน dict ออกมา จะได้ output เป็น tuples นะ `sorted(num.items(), key=lambda x:x[1])`
