Class 1 of Module 2 - Strings in Python Syllabus, VIT
VijayanthVijay
23 views
18 slides
Oct 31, 2025
Slide 1 of 18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
About This Presentation
Class 1 of Module 2 - Strings
Size: 212.63 KB
Language: en
Added: Oct 31, 2025
Slides: 18 pages
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: