Share tuple python

ngoanhoover

New member
## tuple in Python

Một tuple là một tập hợp các mặt hàng trong Python.Nó tương tự như một danh sách, nhưng với một số khác biệt chính.

*** Các mục trong một tuple là bất biến. ** Điều này có nghĩa là chúng không thể thay đổi sau khi chúng được tạo ra.
*** Các bộ dữ liệu được tạo bằng cách sử dụng dấu ngoặc đơn.

`` `Python
t = (1, 2, 3)
`` `

*** Tuples có thể được lập chỉ mục giống như danh sách. ** Mã sau in mục đầu tiên trong tuple `t`:

`` `Python
in (t [0])
`` `

*** Các bộ dữ liệu có thể được giải nén thành các biến. ** Mã sau đây gán các giá trị của tuple `t` cho các biến` a`, `b` và` c`:

`` `Python
A, B, C = T
`` `

Tuples thường được sử dụng để lưu trữ dữ liệu không cần thay đổi.Ví dụ: bạn có thể sử dụng một tuple để lưu trữ tọa độ của một điểm trên biểu đồ.

Dưới đây là một số tài nguyên bổ sung trên các bộ dữ liệu trong Python:

* [Hướng dẫn Tuples Python] (Python Tuples)
* [Hướng dẫn Python: Tuples] (https://docs.python.org/3/tutorial/datsturations.html#tuples)

## hashtags

* #Python
* #tuples
* #cấu trúc dữ liệu
* #Programming
* #learnpython
=======================================
## Tuple in Python

A tuple is a collection of items in Python. It is similar to a list, but with some key differences.

* **Items in a tuple are immutable.** This means that they cannot be changed once they have been created.
* **Tuples are created using parentheses.** For example, the following code creates a tuple with the values `1`, `2`, and `3`:

```python
t = (1, 2, 3)
```

* **Tuples can be indexed just like lists.** The following code prints the first item in the tuple `t`:

```python
print(t[0])
```

* **Tuples can be unpacked into variables.** The following code assigns the values of the tuple `t` to the variables `a`, `b`, and `c`:

```python
a, b, c = t
```

Tuples are often used to store data that does not need to be changed. For example, you could use a tuple to store the coordinates of a point on a graph.

Here are some additional resources on tuples in Python:

* [Python Tuples Tutorial](https://www.w3schools.com/python/python_tuples.asp)
* [The Python Tutorial: Tuples](https://docs.python.org/3/tutorial/datastructures.html#tuples)

## Hashtags

* #Python
* #tuples
* #datastructures
* #Programming
* #learnpython
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top