PYTHON Tutorial
Data structures are fundamental to programming, providing efficient ways to organize and manage data. Python offers various data structures tailored to specific use cases.
list(), tuple(), dict(), set()) to create instances of data structures.[]) or key lookup (e.g., get()) to retrieve data from structures.# Create data structures
my_list = ['apple', 'banana', 'cherry']
my_tuple = ('apple', 'banana', 'cherry')
my_dict = {'apple': 'red', 'banana': 'yellow', 'cherry': 'red'}
my_set = {'apple', 'banana', 'cherry'}
# Operate on structures
my_list.append('mango')
my_dict['orange'] = 'orange'
# Access data
print(my_list[2]) # Output: 'cherry'
print(my_dict['banana']) # Output: 'yellow'