Operations of Strings,
Lists, Tuples, and
Dictionaries in Python
Welcome you all to this fundamental data structures in Python, here we
will be focusing on how to manipulate and work with strings, lists,
tuples, and dictionaries. We will also cover essential operations,
methods, and practical examples to have a deep understanding of the
topic
Group Members
1
Anushree Chatterjee
23BCE11160
2 Varda Joshi
23BCE10345
3
Ayush Arvind
23BCE11017
4 Ritika Sinha
23BCE10196
5
Prince Kumar
23BCE10294
Group no. 2
Introduction to String Operations
What are Strings?
Strings are sequences of characters enclosed in single or
double quotes, representing textual data in Python. They
are immutable, meaning their contents cannot be directly
altered.
Basic Operations
Common string operations include accessing individual
characters, concatenating strings, and checking for
substring presence using the "in" operator.
Slicing, Concatenation,
and Repetition in Strings
1 Slicing
Extracting a substring from
a string based on starting
and ending indices like
"string"[1:4] for characters
1 to 3.
2 Concatenation
Combines multiple strings
using the plus operator (+),
like "Hello" + " World".
3 Repetition
Repeats a string a specified number of times using the asterisk
operator (*), like "Hello" * 3.
List Operations: Creation, Indexing, and
Manipulation
List Creation
Lists are ordered sequences enclosed in square brackets,
storing various data types. They are mutable, allowing
modification of elements.
Indexing and Accessing
Accessing elements in a list is done using their index,
starting from 0. Slicing allows extracting a range of
elements.
List Methods: Append,
Insert, Remove, and Sort
Append
Adds an element to the end of
the list.
Insert
Inserts an element at a
specified index.
Remove
Deletes the first occurrence of
a specified element.
Sort
Sorts the elements of the list
in ascending order.
Tuple Operations:
Immutability and
Accessing Elements
Immutability
Tuples are ordered sequences
enclosed in parentheses. They are
immutable, meaning their
contents cannot be changed after
creation.
Accessing Elements
Elements in a tuple are accessed
using their index, similar to lists.
Dictionary Operations:
Creating, Accessing, and
Updating
1 Creation
Dictionaries are unordered collections of key-value pairs enclosed in
curly braces. Keys must be unique and immutable, while values can
be any data type.
2 Accessing
Elements are accessed using their corresponding keys.
3 Updating
Values associated with existing keys can be modified by assigning
new values.
Dictionary Methods: Get, Keys,
Values, and Items
Get
Retrieves the value associated with a key, providing a default value if the key is
not found.
Keys
Returns a view object containing all the keys in the dictionary.
Values
Returns a view object containing all the values in the dictionary.
Items
Returns a view object containing all the key-value pairs as tuples.
Practical Examples: String, List, Tuple, and
Dictionary Use Cases
1
String Processing
Text manipulation, data cleaning, and natural language processing.
2
List Management
Storing and managing data collections, such as lists of items or users.
3
Tuple Data Structure
Representing immutable data sets like coordinates or database records.
4
Dictionary Lookups
Efficiently storing and accessing data based on unique keys.
Comparison and Selection of Data Structures
1
Strings
Immutable sequences of characters, suitable for text manipulation.
2
Lists
Mutable ordered sequences, ideal for storing and manipulating collections of data.
3
Tuples
Immutable ordered sequences, useful for representing fixed sets of data.
4
Dictionaries
Unordered collections of key-value pairs, suitable for storing
and accessing data based on unique keys.

Operations-of-Strings-Lists-Tuples-and-Dictionaries-in-Python.pptx

  • 1.
    Operations of Strings, Lists,Tuples, and Dictionaries in Python Welcome you all to this fundamental data structures in Python, here we will be focusing on how to manipulate and work with strings, lists, tuples, and dictionaries. We will also cover essential operations, methods, and practical examples to have a deep understanding of the topic
  • 2.
    Group Members 1 Anushree Chatterjee 23BCE11160 2Varda Joshi 23BCE10345 3 Ayush Arvind 23BCE11017 4 Ritika Sinha 23BCE10196 5 Prince Kumar 23BCE10294 Group no. 2
  • 3.
    Introduction to StringOperations What are Strings? Strings are sequences of characters enclosed in single or double quotes, representing textual data in Python. They are immutable, meaning their contents cannot be directly altered. Basic Operations Common string operations include accessing individual characters, concatenating strings, and checking for substring presence using the "in" operator.
  • 4.
    Slicing, Concatenation, and Repetitionin Strings 1 Slicing Extracting a substring from a string based on starting and ending indices like "string"[1:4] for characters 1 to 3. 2 Concatenation Combines multiple strings using the plus operator (+), like "Hello" + " World". 3 Repetition Repeats a string a specified number of times using the asterisk operator (*), like "Hello" * 3.
  • 5.
    List Operations: Creation,Indexing, and Manipulation List Creation Lists are ordered sequences enclosed in square brackets, storing various data types. They are mutable, allowing modification of elements. Indexing and Accessing Accessing elements in a list is done using their index, starting from 0. Slicing allows extracting a range of elements.
  • 6.
    List Methods: Append, Insert,Remove, and Sort Append Adds an element to the end of the list. Insert Inserts an element at a specified index. Remove Deletes the first occurrence of a specified element. Sort Sorts the elements of the list in ascending order.
  • 7.
    Tuple Operations: Immutability and AccessingElements Immutability Tuples are ordered sequences enclosed in parentheses. They are immutable, meaning their contents cannot be changed after creation. Accessing Elements Elements in a tuple are accessed using their index, similar to lists.
  • 8.
    Dictionary Operations: Creating, Accessing,and Updating 1 Creation Dictionaries are unordered collections of key-value pairs enclosed in curly braces. Keys must be unique and immutable, while values can be any data type. 2 Accessing Elements are accessed using their corresponding keys. 3 Updating Values associated with existing keys can be modified by assigning new values.
  • 9.
    Dictionary Methods: Get,Keys, Values, and Items Get Retrieves the value associated with a key, providing a default value if the key is not found. Keys Returns a view object containing all the keys in the dictionary. Values Returns a view object containing all the values in the dictionary. Items Returns a view object containing all the key-value pairs as tuples.
  • 10.
    Practical Examples: String,List, Tuple, and Dictionary Use Cases 1 String Processing Text manipulation, data cleaning, and natural language processing. 2 List Management Storing and managing data collections, such as lists of items or users. 3 Tuple Data Structure Representing immutable data sets like coordinates or database records. 4 Dictionary Lookups Efficiently storing and accessing data based on unique keys.
  • 11.
    Comparison and Selectionof Data Structures 1 Strings Immutable sequences of characters, suitable for text manipulation. 2 Lists Mutable ordered sequences, ideal for storing and manipulating collections of data. 3 Tuples Immutable ordered sequences, useful for representing fixed sets of data. 4 Dictionaries Unordered collections of key-value pairs, suitable for storing and accessing data based on unique keys.