DTech point
Set and String
Python Data Types: Set and String
1. Set Data Type
Definition:
A Set is an unordered collection of unique and immutable elements. It is
mutable, which means elements can be added or removed.
Syntax:
my_set = {1, 2, 3}
Key Characteristics:
1. No duplicate elements.
2. Unordered (no indexing).
3. Mutable (can add or remove elements).
4. Elements must be immutable (like numbers, strings, tuples).
Set Creation:
set1 = {1, 2, 3}
set2 = set([4, 5, 6])
empty_set = set() # Not {}
Set and String
Python Data Types: Set and String
1. Set Data Type
Definition:
A Set is an unordered collection of unique and immutable elements. It is
mutable, which means elements can be added or removed.
Syntax:
my_set = {1, 2, 3}
Key Characteristics:
1. No duplicate elements.
2. Unordered (no indexing).
3. Mutable (can add or remove elements).
4. Elements must be immutable (like numbers, strings, tuples).
Set Creation:
set1 = {1, 2, 3}
set2 = set([4, 5, 6])
empty_set = set() # Not {}