đâu không phải kiểu dữ liệu cơ bản trong python

honglanreilly

New member
## Không phải là loại dữ liệu cơ bản trong Python

Trong Python, danh sách ** ** là một loại dữ liệu hỗn hợp có thể chứa bất kỳ số lượng đối tượng nào và ** Tuples ** là danh sách bất biến.Cả danh sách và bộ dữ liệu đều được coi là loại dữ liệu hỗn hợp vì chúng được tạo thành từ các loại dữ liệu khác.Tuy nhiên, ** các bộ ** không được coi là các loại dữ liệu hợp chất vì chúng không chứa bất kỳ loại dữ liệu nào khác.

Bộ là bộ sưu tập không có thứ tự của các yếu tố độc đáo.Điều này có nghĩa là không có hai yếu tố trong một tập hợp có thể giống nhau.Các bộ được tạo bằng hàm `set ()`.Ví dụ: mã sau tạo một tập hợp các số từ 1 đến 10:

`` `Python
my_set = set (phạm vi (1, 11))
`` `

Chúng ta có thể in các phần tử của một bộ bằng hàm `print ()`:

`` `Python
in (my_set)
`` `

Đầu ra:

`` `
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
`` `

Chúng ta cũng có thể kiểm tra xem một phần tử nằm trong một bộ sử dụng toán tử `in`:

`` `Python
Nếu 5 trong my_set:
in ("5 nằm trong tập hợp")
khác:
in ("5 không có trong tập hợp")
`` `

Đầu ra:

`` `
5 nằm trong tập hợp
`` `

## hashtags

* #Python
* #Loại dữ liệu
* #sets
* #tuples
* #lists
=======================================
## Where is not the basic data type in Python

In Python, a **list** is a compound data type that can hold any number of objects, and **tuples** are immutable lists. Both lists and tuples are considered compound data types because they are made up of other data types. However, **sets** are not considered compound data types because they do not contain any other data types.

Sets are unordered collections of unique elements. This means that no two elements in a set can be the same. Sets are created using the `set()` function. For example, the following code creates a set of the numbers from 1 to 10:

```python
my_set = set(range(1, 11))
```

We can print the elements of a set using the `print()` function:

```python
print(my_set)
```

Output:

```
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
```

We can also check if an element is in a set using the `in` operator:

```python
if 5 in my_set:
print("5 is in the set")
else:
print("5 is not in the set")
```

Output:

```
5 is in the set
```

## Hashtags

* #Python
* #data-types
* #sets
* #tuples
* #lists
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock