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

VijayanthVijay 23 views 18 slides Oct 31, 2025
Slide 1
Slide 1 of 18
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

About This Presentation

Class 1 of Module 2 - Strings


Slide Content

PYTHON Module 2

Strings It’s a series of characters (or numerals). Must be entered at the command prompt or in the code within quotes.

Upper Command Upper command changes the case of the string from lower to UPPER case as follows:

Examples for lower Upper command changes the case of the string from UPPER to lower case as follows:

Capitalize() Capitalize() command changes the case of only the 1 st letter of the string to UPPER to lower case. Changes the first alphabet regardless of the string regardless of the entire string’s case.

Examples for Capitalize() Changes the first alphabet regardless of the string regardless of the entire string’s case.

Swapcase () Reverses the entire string’s individual alphabet’s case.

enumerate() Lists the entire string’s elements one by one, along with its index Does not work on its own Works along with the list command

Index Index is the numerical position of the alphabet inside a string or the position of any element in a list. Helps us access a certain alphabet/character within a string.

String - Length The length of a string shows the number of elements present within it (including quotes). len command

Indexing & String length Indexing of a string(or list) starts with 0. Reason. To access the last element of a string, we must type… string_name [ len – 1]

Example

‘+’ ve & ‘-’ve indices When a ‘+’ve index (starting with ) is entered, it counts the position of string element from L to R and returns the corresponding alphabet.

‘+’ ve & ‘-’ve indices When a ‘-’ve index (starting with 1 ) is entered, it counts the position of string element from R to L and returns the corresponding alphabet.

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

For Loop
Tags