Python - Collections Part 1 | Set, Dictionary, List, Tuple #python #coding @programmatic.ly

preview_player
Показать описание
Sets, Dictionaries, Lists, and Tuples in Python

Sets:
* Unordered collection of unique elements.
* Elements can be of any data type.
* Cannot be indexed or sliced.
* Used for membership testing, intersection, union, difference, and symmetric difference operations.

Dictionaries:
* Unordered collection of key-value pairs.
* Keys must be unique and immutable (e.g., strings, numbers, tuples).
* Values can be of any data type.
* Efficient for accessing elements by key.
* Used to store and retrieve data based on relationships.

Lists:
* Ordered collection of elements.
* Elements can be of any data type.
* Can be indexed and sliced.
* Mutable, allowing elements to be added, removed, or modified.
* Used for storing and manipulating sequences of data.

Tuples:
* Ordered collection of elements.
* Elements can be of any data type.
* Can be indexed and sliced.
* Immutable, meaning elements cannot be changed after creation.
* Often used for representing fixed data structures or as keys in dictionaries.

Example:
# Create a set
my_set = {1, 2, 3, 4}

# Create a dictionary
my_dict = {'name': 'Alice', 'age': 30}

# Create a list
my_list = [10, 20, 30, 40]

# Create a tuple
my_tuple = (5, 6, 7)
Рекомендации по теме
Комментарии
Автор

got it aise ( ) wale brackets dalne hai, funny

durgesh
visit shbcf.ru