Class 2 of Python's Module 2 - available for download.

VijayanthVijay 1 views 30 slides Oct 27, 2025
Slide 1
Slide 1 of 30
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
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30

About This Presentation

Classes 2 & 3 of Python's Module-2


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 Unpacking

Swapping 2 variables Conventional: Python’s method:

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

Example - I

Example - II
Tags