0% found this document useful (0 votes)
3 views2 pages

Python Data Structures Overview

This document provides an overview of Python data structures including lists, tuples, dictionaries, and sets. It outlines their characteristics, such as mutability and order, along with common methods and examples for each structure. The notes serve as a quick reference for understanding and using these data types in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python Data Structures Overview

This document provides an overview of Python data structures including lists, tuples, dictionaries, and sets. It outlines their characteristics, such as mutability and order, along with common methods and examples for each structure. The notes serve as a quick reference for understanding and using these data types in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Data Structures Notes

============================

1. Lists:

- Ordered, mutable, allows duplicates.

- Methods: append(), extend(), pop(), sort().

Example:

my_list = [1, 2, 3]

my_list.append(4) # [1, 2, 3, 4]

2. Tuples:

- Ordered, immutable, allows duplicates.

- Methods: count(), index().

Example:

my_tuple = (1, 2, 3)

print(my_tuple[1]) # 2

3. Dictionaries:

- Unordered, mutable, key-value pairs.

- Methods: get(), keys(), values(), items().

Example:

my_dict = {'a': 1, 'b': 2}

print(my_dict['a']) # 1

4. Sets:

- Unordered, mutable, no duplicates.


- Methods: add(), remove(), union(), intersection().

Example:

my_set = {1, 2, 3}

my_set.add(4) # {1, 2, 3, 4}

You might also like