Class 2 of Python's Module 2 - available for download.
VijayanthVijay
1 views
30 slides
Oct 27, 2025
Slide 1 of 30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
About This Presentation
Classes 2 & 3 of Python's Module-2
Size: 416.07 KB
Language: en
Added: Oct 27, 2025
Slides: 30 pages
Slide Content
PYTHON Module 2
Split method Extracts the individual words separated by spaces, tabs(\t) and new lines(\n)
Cleaning Up Strings Using for and in command it is possible to search for certain unwanted characters in strings and remove them Then a new string can be created using the concatenation operator .
Example Cleaned string with no punctuations.
Formatting strings using placeholders Place holder is a facility in Python to create an empty space to store a value there later. Python allows us to insert any value/string later in the place of the placeholder.
Example
Formatting strings using placeholders
Output(s)
Other examples
Output(s)
Other examples Many other examples found in the book… TRY THEM.
TUPLE It is a complex variable consisting of more than one value. They are entered inside braces and separated by commas as follows.
Examples
TUPLE It is possible to access a particular location within any Tuple. … using Indexing as follows: Tuple Name[index #]
Example
TUPLE Just like strings, Tuples are immutable too. Once Python creates a tuple within its memory, it does not vary its contents later on.
Example
TUPLE While working on real time data, it is sometimes necessary to initially create a tuple with a single value within it. Such tuples are created as follows: Tuple_name = (value,)
Example
Example Note: Without the comma, the type would be string and not tuple.
TUPLE Assignment Python supports Tuple packing & Tuple unpacking Tuple packing is done as follows: Tuple_name = (value1, “value 2” , value 3,)
TUPLE Packing
TUPLE Unpacking Tuple unpacking is the process of storing the variables within a Tuple separately as follows: (V1, V2, V3) = Tuple_name
TUPLE as Fn’s return values Normal fns return only a single value, when the value is a variable . To obtain multiple values from a fn , the variable must be declared as a Tuple instead.
TUPLE as Fn’s return values
Composability of Data Structures A tuple can be a set consisting of multiple tuples (just like a (super)set can consist of many subsets).