Page 130 - TP_Play_V2.2_Class8
P. 130
Take Off Century #Critical Thinking
21 st
Skills #Technology Literacy
Identify and circle the strings in Python from the following:
1. "Name" 2. 'Delhi'
3. 123 4. 23234.54
5. "22323.11" 6. '*&%$#'
LIST
Lists are a fundamental data structure in Python used to store collections of items. A list is
a sequence of multiple values in a specific order. In a list, each element or value is called an
item. A list is mutable, which means the items in a list can be modified by assigning new values.
It is heterogeneous in nature, which means a list can contain numeric as well as textual data.
In this chapter, you will learn about creating a list, operations performed on the list, and the functions
of the list.
CREATING A LIST
Python uses lists to store different types of data in a specific order. Since Python lists are changeable
types, we can change their elements after they’ve been generated.
To create a list, you need to place all the elements separated by a comma inside a square bracket [ ]. The
list can contain any number of elements same or different data types such as integer, float, string etc.
Syntax to Create a List:
<list_name> = [value1, value 2, value 3, ...]
An empty list is a list that does not contain any items in it. The example of the empty list is given as
follows:
To create an empty list:
List1 = []
Some other examples of the list are given as follows:
To create list of 4 integer elements: L1 = [1, 2, 3, 4]
To create list of characters: L1 = [’a’, ’b’, ’c’]
To create list of 3 strings: L1 = [“Nikhil”, “Dikshant”, “Jatin”]
To create list of integer and float numbers: L1 = [1, 1.5, 2.5, 7]
To create list with mixed data types: L1 = [7, “Hello”, 3.14]
128 Plus (Ver. 4.0)-VIII

