Class 2 of Module 2 - Strings in Python Syllabus, VIT
VijayanthVijay
34 views
21 slides
Oct 31, 2025
Slide 1 of 21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
About This Presentation
Class 2 of Module 2 - Strings in Python Syllabus, VIT
Size: 265.34 KB
Language: en
Added: Oct 31, 2025
Slides: 21 pages
Slide Content
PYTHON Module 2
String Concatenation The process of merging two strings. It can be done using the + command.
String Concatenation
Immutability of Strings Once a string is written, it is not possible to alter its individual characters. This property is called immutability .
Immutability of Strings
Alteration using concatenation However, this can be achieved using concatenation, i.e. the + operator .
in Command Searches for character’s or string’s presence within another string.
Example A string is a sub-string of itself. So, the interpreter searches for itself within itself as follows:
not in Command Searches for a character’s or string’s absence within another string.
find function find command checks a string’s or character’s presence within a larger string. Returns the index no. where the character exists or string starts…
Traversal It is the process of going from the very first element of the string to its last element. Traversal can be done using while statement as follows:
Example
Result
Function What is a function? It is a set of instructions written so that it can take any appropriate general input during run time and produce output for it.
For Loop & Counting Using function, a general for loop is created to traverse the string and then … … to count the number of times a certain alphabet occurs within it.
Example
Optional ‘start position’ parameter In the find command, it is possible to start searching for a string from a certain position onwards, instead of the very first position.
Examples
Examples
Py’s built in find function Format : >> “ string”.find (“sub string”) Searches for a sub string within a larger string and displays the index position at the terminal.
Split method Extracts the individual words separated by spaces, tabs(\t) and new lines(\n)