Module-III Strings, Lists and Tuples
Introduction, Creating, Initializing and Accessing Elements of a String, String Indexing, Special
Strings: Initializing and Accessing Elements of a String
Character and Escape Sequence
String slicing, Python Strings are “immutable”, String Operations, String Functions versus String
Slicing - Immutability - Built-in String methods and functions
Methods, Checking for a Palindrome
The ‘+’ Operator Can Concatenate Two Strings, The multiplication operator *,A Short Note on String
Concatenating - Appending and Multiplying Strings - String modules
Module
Introduction, Some Basic Concepts of Lists, Mutability, Creating, Traversing and Slicing Lists,
Lists: Creation - Accessing values – Slicing
Ways of Adding to a List
List Functions and Methods, len, sort, Searching, Adding, Removing, Reversing, and Others,
List methods - Build-in functions - List comprehension
index() Method, List method: pop, List Comprehension
Tuples: Creation - Operations on tuples, Traversing - Indexing Introduction, Creating, initializing and Accessing Elements, Accessing Items in a Tuple and
and Slicing Creating New Tuples from Existing, Creating a Tuple Slice
Tuple assignment - Build-in Functions Tuple assignment, Some Common Tuple Functions
Immutability versus Reassignment - Unpacking tuples Immutability versus Reassignment, Unpacking Tuples
Introduction
• A String is a data structure that represents a sequence of characters.
• String is an immutable data type
• Strings are used such as storing and manipulating text data
like names, addresses
• other types of data that can be represented as text.
Creating, Initializing and Accessing Elements of a
String
• Strings can be created using single, double, triple quotes.
• Individual characters of a String can be accessed by using Indexing.
• Negative indexing to access characters from the back of the String,
Escape sequence
• Escape sequences is to represent certain special characters within string
literals.
• \- put single apostrophe
• \n-to move next line
• \\-to put single backslash between the string
• \b-remove the space between string
Contd..
• \x- to convert hexa value into a string.
Topics & Subtopics:
• Slicing - String slicing
• Immutability -Python Strings are “immutable”,
• Built-in String methods and functions- String Operations, String Functions
versus String Methods, Checking for a Palindrome
Slicing - String slicing
• String slicing is fetching a substring from a given string
• slicing can be done from a ‘start’ index until a ‘stop’ index.
• slice()
• It is a method
• Creates a ‘slice’ object that contains a set of ‘start’ & ‘stop’ indices and step
values.
• slice(stop) // takes start as 0 & step as 1
• slice (start, stop, step)