Page 438 - CITS - Computer Software Application -TT
P. 438
COMPUTER SOFTWARE APPLICATION - CITS
Output:
[1, 2, ‘Python’, ‘Program’, 15.9]
[‘Amy’, ‘Ryan’, ‘Henry’, ‘Emma’]
< class ‘ list ‘ >
< class ‘ list ‘ >
Characteristics of Lists
The characteristics of the List are as follows:
• The lists are in order.
• The list element can be accessed via the index.
• The mutable type of List is
• The rundowns are changeable sorts.
• The number of various elements can be stored in a list.
Ordered List Checking
Code
1 # example
2 a = [ 1, 2, “Ram”, 3.50, “Rahul”, 5, 6 ]
3 b = [ 1, 2, 5, “Ram”, 3.50, “Rahul”, 6 ]
4 a == b
Output:
False
Python Lists are just like dynamically sized arrays, declared in other languages (vector in C++ and ArrayList in
Java). In simple language, a list is a collection of things, enclosed in [ ] and separated by commas.
The list is a sequence data type which is used to store the collection of data. Tuples and String are other types of
sequence data types.
Example of list in Python
Here we are creating Python List using [].
• Python3
Var = [‘NSTI’, ‘Greenery’]
print(Var)
Output:
[‘NSTI’, ‘Greenery’]
Python Lists are just like dynamically sized arrays, declared in other languages (vector in C++ and ArrayList in
Java). In simple language, a list is a collection of things, enclosed in [ ] and separated by commas.
The list is a sequence data type which is used to store the collection of data. Tuples and String are other types of
sequence data types.
Python Lists
mylist = [“apple”, “banana”, “cherry”]
List
Lists are used to store multiple items in a single variable.
425
CITS : IT&ITES - Computer Software Application - Lesson 120 - 137 CITS : IT&ITES - Computer Software Application - Lesson 120 - 137