Class 2 of Module 2 - Strings in Python Syllabus, VIT

VijayanthVijay 34 views 21 slides Oct 31, 2025
Slide 1
Slide 1 of 21
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21

About This Presentation

Class 2 of Module 2 - Strings in Python Syllabus, VIT


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)
Tags