0% found this document useful (0 votes)
6 views68 pages

Python Data Structures Overview

Uploaded by

M Narasimhareddy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views68 pages

Python Data Structures Overview

Uploaded by

M Narasimhareddy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

LIST, TUPLE, DICTIONARY

AND SET
Module 3
LIST - Creation
◦ In Python, a list is a built-in data type used to store multiple items in a single
variable. Here’s how lists work in Python:
LIST - Creation
◦ In Python, a list is a built-in data type used to store multiple items in a single
variable. Here’s how lists work in Python:
LIST - Creation
◦ In Python, a list is a built-in data type used to store multiple items in a single
variable. Here’s how lists work in Python:
LIST - Creation
◦ In Python, a list is a built-in data type used to store multiple items in a single
variable. Here’s how lists work in Python:
List - Accessing
◦ In Python, you can access elements in a list using indexing, slicing, and loops.
List - Accessing
◦ In Python, you can access elements in a list using indexing, slicing, and loops.
List - Accessing
◦ In Python, you can access elements in a list using indexing, slicing, and loops.
List - Accessing
◦ In Python, you can access elements in a list using indexing, slicing, and loops.
Traversing a list
◦ Traversing means accessing each element of a list one by one. You can do this using
loops, list comprehensions, and functions.
The in keyword in Python is used to iterate over elements of a list or check for
membership.
Traversing a list
◦ Traversing means accessing each element of a list one by one. You can do this using
loops, list comprehensions, and functions.
The in keyword in Python is used to iterate over elements of a list or check for
membership.
Traversing a list
◦ Traversing means accessing each element of a list one by one. You can do this using
loops, list comprehensions, and functions.
The in keyword in Python is used to iterate over elements of a list or check for
membership.
Traversing a list
◦ Traversing means accessing each element of a list one by one. You can do this using
loops, list comprehensions, and functions.
The in keyword in Python is used to iterate over elements of a list or check for
membership.
Traversing a list
◦ Traversing means accessing each element of a list one by one. You can do this using
loops, list comprehensions, and functions.
The in keyword in Python is used to iterate over elements of a list or check for
membership.
Nesting in python
◦ Nesting in Python refers to placing one data structure (such as a list, dictionary, or
loop) inside another. It allows for more complex data storage and operations.
Nesting in python
◦ Nesting in Python refers to placing one data structure (such as a list, dictionary, or
loop) inside another. It allows for more complex data storage and operations.
Nesting in python
◦ Nesting in Python refers to placing one data structure (such as a list, dictionary, or
loop) inside another. It allows for more complex data storage and operations.
Comparing Lists
◦ Comparing lists in Python can be done in several ways depending on what exactly
you want to compare. Here are some common methods:
Comparing Lists
◦ Comparing lists in Python can be done in several ways depending on what exactly
you want to compare. Here are some common methods:
Comparing Lists
◦ Comparing lists in Python can be done in several ways depending on what exactly
you want to compare. Here are some common methods:
Comparing Lists
◦ Comparing lists in Python can be done in several ways depending on what exactly
you want to compare. Here are some common methods:
Comparing Lists
◦ Comparing lists in Python can be done in several ways depending on what exactly
you want to compare. Here are some common methods:
List Operations
1. Concatenation
◦ Concatenation is the process of joining two or more lists together to form a new list.
List Operations
2. Repetition
◦ Repetition is the process of repeating a string or list multiple times.
List Operations
3. Slicing
◦ Slicing allows you to extract a subset or slice from a string or list.
List Operations
4. Indexing
◦ Indexing allows you to access individual elements in a string or list.
List Operations
5. Membership Testing
Membership testing checks if a value exists in a sequence (string, list, etc.)
using the in keyword.
Built-In List Functions
Python Built-in List Functions
◦ Python provides several built-in functions to manipulate lists. Below is a breakdown
of commonly used list functions with examples.
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Built-In List Functions
Dictionary
◦ A dictionary in Python is a built-in data type that allows you to store key-value
pairs. It's similar to a real-life dictionary where you look up a word (the key) and get
a definition (the value).

•Keys must be unique and immutable


(e.g., strings, numbers, tuples).

•Values can be any data type.


Dictionary Creation
Dictionary Creation
Accessing Dictionary
Accessing Dictionary
Traversing Dictionary
Traversing Dictionary
Example
Dictionary
◦ A dictionary in Python is a built-in data structure that stores data in key-value
pairs. It's similar to a real-world dictionary where you look up a word (the key) to
get its definition (the value).
Dictionary
◦ A dictionary in Python is a built-in data structure that stores data in key-value
pairs. It's similar to a real-world dictionary where you look up a word (the key) to
get its definition (the value).
Dictionary
◦ A dictionary in Python is a built-in data structure that stores data in key-value
pairs. It's similar to a real-world dictionary where you look up a word (the key) to
get its definition (the value).
Dictionary
◦ A dictionary in Python is a built-in data structure that stores data in key-value
pairs. It's similar to a real-world dictionary where you look up a word (the key) to
get its definition (the value).
Dictionary
Dictionary
Dictionary
Dictionary
Dictionary
Dictionary
Dictionary
Dictionary Functions and
Methods
Dictionary Functions and
Methods
Dictionary Functions and
Methods
Tuples and Sets – Creation and
Operations
1. Tuples
Definition:
• A tuple is an ordered,
immutable collection of
elements.
• Tuples allow duplicate
elements.
Tuples and Sets – Creation and Operations
Tuples and Sets – Creation and
Operations
2. Sets
Definition:
• A set is an unordered,
mutable collection of unique
elements.
• No duplicates allowed.
Tuples and Sets – Creation and Operations

You might also like