SlideShare a Scribd company logo
Mrs. Payal Bhattacharjee, PGT(C.Sc.)
K V No.1 Kanchrapara
KVS-RO(Kolkata)
Know Python Bytes
www.knowpythonbytes.blogspot.com
FINAL revised LIST in Python.pdf
 Lists Introduction: Definition, Creation of a list, Traversal of a list.
 Operations on a list – concatenation/joining, repetition/replication,
membership, Comparison of Lists;
 Functions/methods–len(), list(),append(), extend(), insert(), count(),
index(), remove(), pop(), reverse(), sort(),min(), max(), sum()
 Lists Slicing;
 Nested lists;
 finding the maximum, minimum, mean of numeric values stored in a list
 linear search on list of numbers
 counting the frequency of elements in a list
CONTENTS
( Learning Outcomes ) 
XI CS 2020-21
XI IP 2020-21
Lists: list operations - creating, initializing, traversing and manipulating
LIST in Python
FINAL revised LIST in Python.pdf
What is a LIST ?
• A list is a collections of items which are
formed by placing a comma-separated-
list of expressions in square brackets.
• Each item/element has its own index
number.
• Index of first item is 0 and the last item
is n-1. Here n is number of items in a
list.
• Lists are mutable sequences i.e. we can
change elements of a list in place.
• Lists can contain values of mixed data
types.
Lists Intro:
List Definition
Indexing in a List
Creation of a list
Traversal of a list.
Operations on a list -
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
INDEXING in a LIST
0 1 2 3 4 5
-6 -5 -4 -3 -2 -1
B A C K W A R D I N D E X D I R E C T I O N
10 20 30 40 50 60
F O R W A R D I N D E X D I R E C T I O N
NOTE:-
The index (also called subscript) is the numbered
position of a letter in the LIST. In python, indices begin
from
0,1,2,…. upto (length-1) in the forward
direction and
-1,-2,-3,….. (-length) in the backward direction.
where length is the length of the List.
Lists Intro:
List Definition
Indexing in a List
Creation of a list
Traversal of a list
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
CREATION of LIST
Lists Intro:
List Definition
Indexing in a List
Creation of a list
Traversal of a list
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
List of numbers created without name
List of characters created without name
List of mixed data type created without
name
List of numbers with name L
Empty List created without name
Empty List created with name L
Empty List created with name l using
funcion list()
CONTENTS
Creation of LIST contd..(Long List and Nested List)
Creation of a long listwith name MultiTens
Creation of a Nested List with name L
that is List inside a List
Lists Intro:
List Definition
Indexing in a List
Creation of a list
Traversal of a list
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
Creation of LIST from existing sequences
Creating list from string
Creating list by taking input from the keyboard(user)
Creating list from tuple
**Note: All the elements are considered as string
Creating list by taking input from the keyboard [using eval()]
]method]
**Note: eval( ) identifies the type by looking at the given
expression
Lists Intro:
List Definition
Indexing in a List
Creation of a list
from string,tuple,
list(input()),
eval(input())
Traversal of a list
Assign/change values in List
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
Lists Intro:
List Definition
Indexing in a List
Creation of a list
Traversal of a list
Assign /change values in List
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
TRAVERSAL of a LIST
CONTENTS
Lists Intro:
List Definition
Indexing in a List
Creation of a list
Traversal of a list
Assign /change values in List
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
TRAVERSAL of NESTED LIST
Nested List 1 Nested List 2
Enclosing List
Note: Denoting Nested elements
using Index nos.
M[0]  10
M[1]  [15,30]
M[1][0]15
M[1][1]30
M[2] *80,’Mask’,60+
M[2][0]80
M[2][1]‘Mask’
M[2][2]60
CONTENTS
Lists Intro:
List Definition
Indexing in a List
Creation of a list
Traversal of a list
Assign /change
values in List
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
Assign/Change values in a LIST
Assigning
/ Changing
values of
elements
of a List
Assigning /
Changing
values of
elements of
a List
Forward Index 0 1 2 3
-4 -3 -2 -1 Backward index
FINAL revised LIST in Python.pdf
Lists Introduction:
OPERATIONS
ON List
Concatenation/Joining
Repetition/Replication
Membership
Comparison of Lists
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS List CAN be concatenated or
joined with another List
List CANNOT be concatenated with a number
List CANNOT be concatenated with a string
List CANNOT be joined with a complex nos.
List CAN be concatenated or
joined with another List
Concatenation refers
to Joining of two
objects
OPERATIONS on LIST Concatenation
CONTENTS
Lists Introduction:
OPERATIONS
ON List
Concatenation/Joining
Repetition/
Replication
Membership
Comparison of Lists
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
OPERATIONS on LIST Replication
Replicating the unnamed List two times
Replicating the named List RL four times
Replication refers to Repetition of objects as it
is. Here, in LIST we can see NON-VECTORISED
operation with a list where the entire list as a
whole is replicated.
NOTE: Vectorised operation, refers to the
replication of individual elements of the object.
CONTENTS
OPERATOR DESCRIPTION
in Results to True value if it finds a variable at the LHS of in
operator in the sequence mentioned in the RHS of the in
operator, else it returns False
not in Results to True value if it does not find a variable at the
LHS of in operator in the sequence mentioned in the RHS
of the in operator, else it returns False
Membership operator tests for Membership in a sequence.
Returns Boolean True or False
Lists Introduction:
OPERATIONS
ON List
Concatenation/Joining
Repetition/
Replication
Membership
in List
Comparison of Lists
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
OPERATIONS on LIST Membership
CONTENTS Comparison of list returns Boolean True or False.
Lists Introduction:
OPERATIONS
ON List
Concatenation/Joining
Repetition/
Replication
Membership in List
Comparison
of Lists
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
OPERATIONS on Comparison of LIST
Eg. List CANNOT be
compared with a number
Relational operators
==,!=,<,<=,>,>= are used
in comparing two objects.
Here, for example two List
objects are compared.
Relational operators ==,!=
can be used in comparing
two objects eg. List with
number/string/tuple. But,
Relational operators
<,<=,>,>= always returns
ERROR when used in
comparing two objects eg.
List with
number/string/tuple.
FINAL revised LIST in Python.pdf
Functions / Methods on LIST-len()
TOTAL 5 elements of the List object
len() function counts the no. of elements in the List
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(), insert(),
count(),index(), remove(),
pop(), reverse(), sort(),
min(), max(), sum(),clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(), insert(),
count(),index(), remove(),
pop(), reverse(), sort(),
min(), max(), sum(),clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
Functions / Methods on LIST-list()
The list() function creates a list object.
A list object is a collection which is ordered and
changeable.
list() function
takes
elements/values
inside the
parantheses i.e. ()
NOTE: Python language is case-sensitive.
Here, Z is the List object , so, z in small letters gives an error.
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(), insert(),
count(),index(), remove(),
pop(), reverse(),
sort(),min(), max(),
sum(),clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
CONTENTS The append() function takes one single parameter
and adds exactly one element at the end of the List.
It takes exactly one element and returns no value.
Here, append() function takes one single
parameter . In this example, 30.
Functions / Methods on LIST-append()
Lists Introduction:
Operations on a list
Functions/methods
len(), list(),append(),
extend(), insert(),
count(),index(), remove(),
pop(), reverse(), sort(),
min(), max(), sum(),clear()
 Lists Slicing;
 Nested lists;
finding the max,min, mean
 linear search on list
 counting the frequency
The extend() function adds iterable (Eg. Another List/
Tuple/String) at the end of the List.
Here, trying to extend list A , with another
unnamed List containing one element [30].
Functions / Methods on LIST-extend()
CONTENTS
Here, trying to extend list A , with
another unnamed List containing
three elements [4,50,77].
Here, trying to extend list A , with
another named List B containing
three elements
*‘know’,’python’,’bytes’+
Here, trying to extend list A , with a number 10. Hence error !!!
NOTE: A no. inside parentheses () is not a tuple,
until it ends with a comma ,
Here, trying to extend list A , with an unnamed tuple with two values
Here, trying to extend list A , with a string.
Every character is considered as an element of the list.
Lists Introduction:
Operations on a list
Functions/methods
len(), list(),append(), extend(),
insert(), count(),index(),
remove(), pop(), reverse(),
sort(),min(), max(),
sum(),clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
Functions / Methods on LIST- insert()
insert( ) method,
inserts an item / element at a given position.
It takes two arguments and returns no value.
ListObject.insert(<position>,<item>)
Position denotes the index no.
Item denotes the item/element/value to be inserted.
Forward Index 0 1 2
-3 -2 -1 Backward index
NOTE: Whenever the element is inserted,
whether forward or backward index… it is
always inserted at the left hand side of the
current index item’s position.
Prepended inserted at the beginning i.e.
index 0
Appended  inserted at the last
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(), insert(),
count()
,index(),remove(), pop(),
reverse(), sort(),min(),
max(), sum(), clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
Functions / Methods on LIST- count()
count( ) method,
returns the count of the item (no. of times the
item /element/value appears) that is passed as
argument. If the given item is not in the list, it
will return 0
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(), extend(),
insert(),count(), index(),
remove(), pop(), reverse(),
sort(),min(), max(), sum() ,
clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
Functions / Methods on LIST- index()
index( ) method,
returns the index of the first matched item.
Forward
Index 0 1 2 3 4 5
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(), extend(),
insert(),count(),index(),
remove(), pop(),
reverse(), sort(),min(), max(),
sum() , clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
CONTENTS
Functions / Methods on LIST- remove()
remove( ) method,
removes the first occurrence of given item from the
list (from left-to-right)
remove( ) will report an error if there is no such value.
CONTENTS
Functions / Methods on LIST- pop()
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(),
insert(),count(),index(),
remove(), pop(),
reverse(), sort(),min(),
max(), sum() , clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
pop( ) method is used to remove the item from the list.
It takes one optional argument . The element being deleted
is returned by the method
DIFFERENCE between pop() and
remove()
The pop( ) method removes an
individual item (from the right most
end  by default) or the
value/element present at the index
number mentioned in the parameter
and returns it. Whereas remove( )
searches the first occurrence of the
item and removes it from the list
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(), extend(),
insert(),count(),index(),
remove(), pop(),
reverse(), sort(),min(),
max(), sum(),clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
Functions / Methods on LIST- reverse()
reverse( ) method,
reverses the items of the list.
This doesn’t create a new list.
It takes no argument and return no list.
Reverses the list ‘in place’ and does not
return anything.
CONTENTS
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(),
insert(),count(),index(),
remove(), pop(), reverse(),
sort(),min(), max(),
sum() , clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
Functions / Methods on LIST- sort()
sort( ) method,
sort( ) method and sort(reverse=True ) sorts or
orders the items of the list, by default in increasing order.
sort(reverse=True ) for getting the list in decreasing order
CONTENTS
NOTE: The sort( ) method
won’t be able to sort the
values of a list if it contains
complex numbers/tuple
/ mixed datatype as its
elements.
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(),
insert(),count(),index(),
remove(), pop(), reverse(),
sort(),min(),
max(), sum(),
clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
min( ) method,
Returns the minimum out of the elements/values/items of
the given List
CONTENTS
Functions / Methods on LIST- min(),max(),sum()
sum( ) method,
Returns the sum of all the values/elements/items of the
given List.
max( ) method,
Returns the maximum out of the elements/values/items of
the given List
Functions / Methods on LIST- min(),max(),sum() contd..
A List with
mixed data
type cannot
return values
for the min,
max and
sum
functions.
List of string . Maximum
and Minimum is done on
the basis of the ASCII
values of the characters
from the beginning.
Eg. ‘A’=65, ‘a’ = 97, ‘b’=98
and so on
Lists Introduction:
Operations on a list
Functions/
methods
len(), list(),append(),
extend(),
insert(),count(),index(),
remove(), pop(), reverse(),
sort(),min(), max(), sum() ,
clear()
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
Functions / Methods on LIST- clear()
clear( ) method,
removes all the items from the list and
the list becomes empty after executing
this function.
CONTENTS
FINAL revised LIST in Python.pdf
LIST slicing
L[start:stop] creates a list slice out of list L with elements falling between
indexes start and stop, not including value at the stop index.
L[start:stop:step] creates a list slice out of list L with elements falling
between indexes start and stop, not including value at the stop index, and skipping
step elements in between.
B A C K W A R D I N D E X D I R E C T I O N
K N O W P Y T H O N B Y T E S
F O R W A R D I N D E X D I R E C T I O N
-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
NOTE: In absence of any start, stop, step values, we have Default start index as the beginning,
stop index as the last index and step value as +1.
K N O W P Y T H O N B Y T E S
-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
LIST slicing
Start index 3, stop index is (10-1=9)
Start index 5, stop index is 50 which is beyond the last index in forward
direction. Hence, it will stop at the last index
Start index -4(backward), stop index is (6-1=5 (forward)). Here, it is
not getting any value in the range, hence empty.
Start index -4(which is ‘Y’ as per the backward index,) stop index is 25
which is beyond the last index. Hence, it will stop at the last index.
Start index 10, stop index is 30 which is beyond the
last index in forward direction. Hence, it will stop at
the last index
Start index -10(which is ‘Y’ as per the backward index,) stop index is 12-1=11
(forward indexing). Hence, it will stop at the (stop index-1)., ‘Y’ is at 11 index no.
K N O W P Y T H O N B Y T E S
-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Start index -20(which is beyond backward index,) stop
index is -5 which takes value till (-5-1=-6). Here, -6 is ‘N’.
Start index 1, stop index is 13 (till 13-1=12),step value
is 2 in forward direction. Hence, it will fetch/take
alternate elements with a skip of 1 value in between
Start index -3(backward), stop index is -12(backward). Here, it is not getting
any value in the range as no step value mentioned in reverse. Hence empty.
Start index -12(which is ‘W’ as per the backward index,)
stop index is -3 (which takes values till index -3-1= -4)
Start index -3(backward), stop index is -12(backward). Here, it is getting
value in the range as step value is -1 mentioned in reverse.
TRY TO UNDERSTAND YOURSELF. A task for you.
Also write the slice for List to get the output as
LIST SLICING contd.
Default start and stop is beginning and end index of the list. Here, step is 3.
?
FINAL revised LIST in Python.pdf
CONTENTS
Lists Intro
Operations on a list
Functions/methods
 Lists Slicing;
 Nested lists;
finding the maximum,
minimum, mean
 linear search on list
 counting the frequency
NESTED LISTS
Nested List 1 Nested List 2
Enclosing List
Note: Denoting Nested elements
using Index nos.
M[0]  10
M[1]  [15,30]
M[1][0]15
M[1][1]30
M[2] *80,’Mask’,60+
M[2][0]80
M[2][1]‘Mask’
M[2][2]60
FINAL revised LIST in Python.pdf
Lists Intro
Operations on
a list
Functions/
methods
 Lists Slicing;
 Nested lists;
finding
the
maximum
, minimum, mean
 linear search
on list
 counting the
frequency
Program to find the MAXIMUM element from a list of element along
with its index in the list without using max() library function
OUTPUT
CONTENTS
Lists Intro
Operations on a
list
Functions/
methods
 Lists Slicing;
 Nested lists;
finding
the
minimum,
maximum , mean
 linear search
on list
 counting the
frequency
Program to find the MINIMUM element from a list of element along
with its index in the list without using min() library function
CONTENTS
OUTPUT
Lists Intro
Operations on a
list
Functions/
methods
 Lists Slicing;
 Nested lists;
finding
the mean,
maximum,
minimum
 linear search
on list
 counting the
frequency
Program to find the MEAN (AVERAGE) of all the elements of
the list
CONTENTS
OUTPUT
CONTENTS
Lists Intro
Operations on a
list
Functions/
methods
 Lists Slicing;
 Nested lists;
finding the
mean, maximum,
minimum
 linear
search on
list
 counting the
frequency OUTPUT
Program to search an element in the List (LINEAR SEARCH)
CONTENTS
Lists Intro
Operations on a
list
Functions/
methods
 Lists Slicing;
 Nested lists;
finding the
mean, maximum,
minimum
 linear search
on list

counting
the
frequency
OUTPUT
Program to count frequency (/no. of times of occurrence) of an element in the List
(FREQUENCY COUNT)
Bibliograhy and References
• Google
• Wikipedia
• XI Computer Science , By Sumita Arora,
Dhanpat Rai Publication 2020 Edition
• XI Informatics Practices , By Sumita Arora,
Dhanpat Rai Publication 2020 Edition
Programming is an ART….
Add your colours to it and make your own

More Related Content

DOCX
3 d searching document
PPT
Word Dictionary - Software Development Project 1
PPTX
Publishing and delivery of mobile application
PPTX
Airline Management System [for presentation]
PPTX
Android Preferences
PPTX
Visibility control in java
PDF
File Types in Data Structure
PPTX
Content provider in_android
3 d searching document
Word Dictionary - Software Development Project 1
Publishing and delivery of mobile application
Airline Management System [for presentation]
Android Preferences
Visibility control in java
File Types in Data Structure
Content provider in_android

What's hot (20)

PPSX
JDBC: java DataBase connectivity
DOCX
Airline Reservation System Documentation
PDF
Designing Web Interfaces
PPTX
Constructor ppt
PPTX
Program activation records
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
PPTX
The impact of web on ir
PPTX
Package in Java
PDF
Android resource
PPSX
Designing of Video Player with Python
PPTX
Socket programming in Java (PPTX)
PDF
Dbms 14: Relational Calculus
PPTX
Oop’s Concept and its Real Life Applications
DOC
Airline management system
PPTX
Variables in python
PPTX
File handling in C
PPTX
Lecture 1 introduction to vb.net
PPTX
CSE Final Year Project Presentation on Android Application
PPT
Request dispatching in servlet
PPT
File structures
JDBC: java DataBase connectivity
Airline Reservation System Documentation
Designing Web Interfaces
Constructor ppt
Program activation records
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
The impact of web on ir
Package in Java
Android resource
Designing of Video Player with Python
Socket programming in Java (PPTX)
Dbms 14: Relational Calculus
Oop’s Concept and its Real Life Applications
Airline management system
Variables in python
File handling in C
Lecture 1 introduction to vb.net
CSE Final Year Project Presentation on Android Application
Request dispatching in servlet
File structures
Ad

Similar to FINAL revised LIST in Python.pdf (20)

PPTX
LM 28 - List (Operations, Slice, Methods).pptx
PDF
Python list functions
PPTX
Python Dynamic Data type List & Dictionaries
PPTX
Lecture2.pptx
PPTX
Data -structures for class 12 , easy ppt
PPTX
11 Introduction to lists.pptx
PPTX
lists_list_of_liststuples_of_python.pptx
PPTX
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
PPTX
python ..... _
PDF
Python Unit 5 Questions n Notes.pdf
PPTX
Python Array Power Point Presentation.pptx
PPTX
Lists on the pyhton to learn the children more easily on easy codes.pptx
PPTX
Data structures: linear lists
PDF
Python-Ukllllllllllllllllllllllllllllnit 2.pdklllllllf
PDF
Python lists &amp; sets
PDF
List in Python Using Back Developers in Using More Use.
PPTX
list in python and traversal of list.pptx
PPTX
General Data structures
PPTX
linked list in dsa python (presentation)
LM 28 - List (Operations, Slice, Methods).pptx
Python list functions
Python Dynamic Data type List & Dictionaries
Lecture2.pptx
Data -structures for class 12 , easy ppt
11 Introduction to lists.pptx
lists_list_of_liststuples_of_python.pptx
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
python ..... _
Python Unit 5 Questions n Notes.pdf
Python Array Power Point Presentation.pptx
Lists on the pyhton to learn the children more easily on easy codes.pptx
Data structures: linear lists
Python-Ukllllllllllllllllllllllllllllnit 2.pdklllllllf
Python lists &amp; sets
List in Python Using Back Developers in Using More Use.
list in python and traversal of list.pptx
General Data structures
linked list in dsa python (presentation)
Ad

Recently uploaded (20)

PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
assetexplorer- product-overview - presentation
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
ai tools demonstartion for schools and inter college
PPTX
Transform Your Business with a Software ERP System
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
System and Network Administraation Chapter 3
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Introduction to Artificial Intelligence
Designing Intelligence for the Shop Floor.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
assetexplorer- product-overview - presentation
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Reimagine Home Health with the Power of Agentic AI​
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
wealthsignaloriginal-com-DS-text-... (1).pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
ai tools demonstartion for schools and inter college
Transform Your Business with a Software ERP System
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Which alternative to Crystal Reports is best for small or large businesses.pdf
System and Network Administraation Chapter 3
PTS Company Brochure 2025 (1).pdf.......
Digital Strategies for Manufacturing Companies
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Introduction to Artificial Intelligence

FINAL revised LIST in Python.pdf

  • 1. Mrs. Payal Bhattacharjee, PGT(C.Sc.) K V No.1 Kanchrapara KVS-RO(Kolkata) Know Python Bytes www.knowpythonbytes.blogspot.com
  • 3.  Lists Introduction: Definition, Creation of a list, Traversal of a list.  Operations on a list – concatenation/joining, repetition/replication, membership, Comparison of Lists;  Functions/methods–len(), list(),append(), extend(), insert(), count(), index(), remove(), pop(), reverse(), sort(),min(), max(), sum()  Lists Slicing;  Nested lists;  finding the maximum, minimum, mean of numeric values stored in a list  linear search on list of numbers  counting the frequency of elements in a list CONTENTS ( Learning Outcomes )  XI CS 2020-21 XI IP 2020-21 Lists: list operations - creating, initializing, traversing and manipulating LIST in Python
  • 5. What is a LIST ? • A list is a collections of items which are formed by placing a comma-separated- list of expressions in square brackets. • Each item/element has its own index number. • Index of first item is 0 and the last item is n-1. Here n is number of items in a list. • Lists are mutable sequences i.e. we can change elements of a list in place. • Lists can contain values of mixed data types. Lists Intro: List Definition Indexing in a List Creation of a list Traversal of a list. Operations on a list - Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS
  • 6. INDEXING in a LIST 0 1 2 3 4 5 -6 -5 -4 -3 -2 -1 B A C K W A R D I N D E X D I R E C T I O N 10 20 30 40 50 60 F O R W A R D I N D E X D I R E C T I O N NOTE:- The index (also called subscript) is the numbered position of a letter in the LIST. In python, indices begin from 0,1,2,…. upto (length-1) in the forward direction and -1,-2,-3,….. (-length) in the backward direction. where length is the length of the List. Lists Intro: List Definition Indexing in a List Creation of a list Traversal of a list Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS
  • 7. CREATION of LIST Lists Intro: List Definition Indexing in a List Creation of a list Traversal of a list Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS List of numbers created without name List of characters created without name List of mixed data type created without name List of numbers with name L Empty List created without name Empty List created with name L Empty List created with name l using funcion list()
  • 8. CONTENTS Creation of LIST contd..(Long List and Nested List) Creation of a long listwith name MultiTens Creation of a Nested List with name L that is List inside a List Lists Intro: List Definition Indexing in a List Creation of a list Traversal of a list Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency
  • 9. CONTENTS Creation of LIST from existing sequences Creating list from string Creating list by taking input from the keyboard(user) Creating list from tuple **Note: All the elements are considered as string Creating list by taking input from the keyboard [using eval()] ]method] **Note: eval( ) identifies the type by looking at the given expression Lists Intro: List Definition Indexing in a List Creation of a list from string,tuple, list(input()), eval(input()) Traversal of a list Assign/change values in List Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency
  • 10. Lists Intro: List Definition Indexing in a List Creation of a list Traversal of a list Assign /change values in List Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS TRAVERSAL of a LIST
  • 11. CONTENTS Lists Intro: List Definition Indexing in a List Creation of a list Traversal of a list Assign /change values in List Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency TRAVERSAL of NESTED LIST Nested List 1 Nested List 2 Enclosing List Note: Denoting Nested elements using Index nos. M[0]  10 M[1]  [15,30] M[1][0]15 M[1][1]30 M[2] *80,’Mask’,60+ M[2][0]80 M[2][1]‘Mask’ M[2][2]60
  • 12. CONTENTS Lists Intro: List Definition Indexing in a List Creation of a list Traversal of a list Assign /change values in List Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency Assign/Change values in a LIST Assigning / Changing values of elements of a List Assigning / Changing values of elements of a List Forward Index 0 1 2 3 -4 -3 -2 -1 Backward index
  • 14. Lists Introduction: OPERATIONS ON List Concatenation/Joining Repetition/Replication Membership Comparison of Lists Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS List CAN be concatenated or joined with another List List CANNOT be concatenated with a number List CANNOT be concatenated with a string List CANNOT be joined with a complex nos. List CAN be concatenated or joined with another List Concatenation refers to Joining of two objects OPERATIONS on LIST Concatenation
  • 15. CONTENTS Lists Introduction: OPERATIONS ON List Concatenation/Joining Repetition/ Replication Membership Comparison of Lists Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency OPERATIONS on LIST Replication Replicating the unnamed List two times Replicating the named List RL four times Replication refers to Repetition of objects as it is. Here, in LIST we can see NON-VECTORISED operation with a list where the entire list as a whole is replicated. NOTE: Vectorised operation, refers to the replication of individual elements of the object.
  • 16. CONTENTS OPERATOR DESCRIPTION in Results to True value if it finds a variable at the LHS of in operator in the sequence mentioned in the RHS of the in operator, else it returns False not in Results to True value if it does not find a variable at the LHS of in operator in the sequence mentioned in the RHS of the in operator, else it returns False Membership operator tests for Membership in a sequence. Returns Boolean True or False Lists Introduction: OPERATIONS ON List Concatenation/Joining Repetition/ Replication Membership in List Comparison of Lists Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency OPERATIONS on LIST Membership
  • 17. CONTENTS Comparison of list returns Boolean True or False. Lists Introduction: OPERATIONS ON List Concatenation/Joining Repetition/ Replication Membership in List Comparison of Lists Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency OPERATIONS on Comparison of LIST Eg. List CANNOT be compared with a number Relational operators ==,!=,<,<=,>,>= are used in comparing two objects. Here, for example two List objects are compared. Relational operators ==,!= can be used in comparing two objects eg. List with number/string/tuple. But, Relational operators <,<=,>,>= always returns ERROR when used in comparing two objects eg. List with number/string/tuple.
  • 19. Functions / Methods on LIST-len() TOTAL 5 elements of the List object len() function counts the no. of elements in the List Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(), count(),index(), remove(), pop(), reverse(), sort(), min(), max(), sum(),clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS
  • 20. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(), count(),index(), remove(), pop(), reverse(), sort(), min(), max(), sum(),clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS Functions / Methods on LIST-list() The list() function creates a list object. A list object is a collection which is ordered and changeable. list() function takes elements/values inside the parantheses i.e. () NOTE: Python language is case-sensitive. Here, Z is the List object , so, z in small letters gives an error.
  • 21. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(), count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum(),clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list CONTENTS The append() function takes one single parameter and adds exactly one element at the end of the List. It takes exactly one element and returns no value. Here, append() function takes one single parameter . In this example, 30. Functions / Methods on LIST-append()
  • 22. Lists Introduction: Operations on a list Functions/methods len(), list(),append(), extend(), insert(), count(),index(), remove(), pop(), reverse(), sort(), min(), max(), sum(),clear()  Lists Slicing;  Nested lists; finding the max,min, mean  linear search on list  counting the frequency The extend() function adds iterable (Eg. Another List/ Tuple/String) at the end of the List. Here, trying to extend list A , with another unnamed List containing one element [30]. Functions / Methods on LIST-extend() CONTENTS Here, trying to extend list A , with another unnamed List containing three elements [4,50,77]. Here, trying to extend list A , with another named List B containing three elements *‘know’,’python’,’bytes’+ Here, trying to extend list A , with a number 10. Hence error !!! NOTE: A no. inside parentheses () is not a tuple, until it ends with a comma , Here, trying to extend list A , with an unnamed tuple with two values Here, trying to extend list A , with a string. Every character is considered as an element of the list.
  • 23. Lists Introduction: Operations on a list Functions/methods len(), list(),append(), extend(), insert(), count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum(),clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS Functions / Methods on LIST- insert() insert( ) method, inserts an item / element at a given position. It takes two arguments and returns no value. ListObject.insert(<position>,<item>) Position denotes the index no. Item denotes the item/element/value to be inserted. Forward Index 0 1 2 -3 -2 -1 Backward index NOTE: Whenever the element is inserted, whether forward or backward index… it is always inserted at the left hand side of the current index item’s position. Prepended inserted at the beginning i.e. index 0 Appended  inserted at the last
  • 24. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(), count() ,index(),remove(), pop(), reverse(), sort(),min(), max(), sum(), clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS Functions / Methods on LIST- count() count( ) method, returns the count of the item (no. of times the item /element/value appears) that is passed as argument. If the given item is not in the list, it will return 0
  • 25. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(),count(), index(), remove(), pop(), reverse(), sort(),min(), max(), sum() , clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS Functions / Methods on LIST- index() index( ) method, returns the index of the first matched item. Forward Index 0 1 2 3 4 5
  • 26. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(),count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum() , clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency CONTENTS Functions / Methods on LIST- remove() remove( ) method, removes the first occurrence of given item from the list (from left-to-right) remove( ) will report an error if there is no such value.
  • 27. CONTENTS Functions / Methods on LIST- pop() Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(),count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum() , clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency pop( ) method is used to remove the item from the list. It takes one optional argument . The element being deleted is returned by the method DIFFERENCE between pop() and remove() The pop( ) method removes an individual item (from the right most end  by default) or the value/element present at the index number mentioned in the parameter and returns it. Whereas remove( ) searches the first occurrence of the item and removes it from the list
  • 28. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(),count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum(),clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency Functions / Methods on LIST- reverse() reverse( ) method, reverses the items of the list. This doesn’t create a new list. It takes no argument and return no list. Reverses the list ‘in place’ and does not return anything. CONTENTS
  • 29. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(),count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum() , clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency Functions / Methods on LIST- sort() sort( ) method, sort( ) method and sort(reverse=True ) sorts or orders the items of the list, by default in increasing order. sort(reverse=True ) for getting the list in decreasing order CONTENTS NOTE: The sort( ) method won’t be able to sort the values of a list if it contains complex numbers/tuple / mixed datatype as its elements.
  • 30. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(),count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum(), clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency min( ) method, Returns the minimum out of the elements/values/items of the given List CONTENTS Functions / Methods on LIST- min(),max(),sum() sum( ) method, Returns the sum of all the values/elements/items of the given List. max( ) method, Returns the maximum out of the elements/values/items of the given List
  • 31. Functions / Methods on LIST- min(),max(),sum() contd.. A List with mixed data type cannot return values for the min, max and sum functions. List of string . Maximum and Minimum is done on the basis of the ASCII values of the characters from the beginning. Eg. ‘A’=65, ‘a’ = 97, ‘b’=98 and so on
  • 32. Lists Introduction: Operations on a list Functions/ methods len(), list(),append(), extend(), insert(),count(),index(), remove(), pop(), reverse(), sort(),min(), max(), sum() , clear()  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency Functions / Methods on LIST- clear() clear( ) method, removes all the items from the list and the list becomes empty after executing this function. CONTENTS
  • 34. LIST slicing L[start:stop] creates a list slice out of list L with elements falling between indexes start and stop, not including value at the stop index. L[start:stop:step] creates a list slice out of list L with elements falling between indexes start and stop, not including value at the stop index, and skipping step elements in between. B A C K W A R D I N D E X D I R E C T I O N K N O W P Y T H O N B Y T E S F O R W A R D I N D E X D I R E C T I O N -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 NOTE: In absence of any start, stop, step values, we have Default start index as the beginning, stop index as the last index and step value as +1.
  • 35. K N O W P Y T H O N B Y T E S -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 LIST slicing Start index 3, stop index is (10-1=9) Start index 5, stop index is 50 which is beyond the last index in forward direction. Hence, it will stop at the last index Start index -4(backward), stop index is (6-1=5 (forward)). Here, it is not getting any value in the range, hence empty. Start index -4(which is ‘Y’ as per the backward index,) stop index is 25 which is beyond the last index. Hence, it will stop at the last index. Start index 10, stop index is 30 which is beyond the last index in forward direction. Hence, it will stop at the last index Start index -10(which is ‘Y’ as per the backward index,) stop index is 12-1=11 (forward indexing). Hence, it will stop at the (stop index-1)., ‘Y’ is at 11 index no.
  • 36. K N O W P Y T H O N B Y T E S -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Start index -20(which is beyond backward index,) stop index is -5 which takes value till (-5-1=-6). Here, -6 is ‘N’. Start index 1, stop index is 13 (till 13-1=12),step value is 2 in forward direction. Hence, it will fetch/take alternate elements with a skip of 1 value in between Start index -3(backward), stop index is -12(backward). Here, it is not getting any value in the range as no step value mentioned in reverse. Hence empty. Start index -12(which is ‘W’ as per the backward index,) stop index is -3 (which takes values till index -3-1= -4) Start index -3(backward), stop index is -12(backward). Here, it is getting value in the range as step value is -1 mentioned in reverse. TRY TO UNDERSTAND YOURSELF. A task for you. Also write the slice for List to get the output as LIST SLICING contd. Default start and stop is beginning and end index of the list. Here, step is 3. ?
  • 38. CONTENTS Lists Intro Operations on a list Functions/methods  Lists Slicing;  Nested lists; finding the maximum, minimum, mean  linear search on list  counting the frequency NESTED LISTS Nested List 1 Nested List 2 Enclosing List Note: Denoting Nested elements using Index nos. M[0]  10 M[1]  [15,30] M[1][0]15 M[1][1]30 M[2] *80,’Mask’,60+ M[2][0]80 M[2][1]‘Mask’ M[2][2]60
  • 40. Lists Intro Operations on a list Functions/ methods  Lists Slicing;  Nested lists; finding the maximum , minimum, mean  linear search on list  counting the frequency Program to find the MAXIMUM element from a list of element along with its index in the list without using max() library function OUTPUT CONTENTS
  • 41. Lists Intro Operations on a list Functions/ methods  Lists Slicing;  Nested lists; finding the minimum, maximum , mean  linear search on list  counting the frequency Program to find the MINIMUM element from a list of element along with its index in the list without using min() library function CONTENTS OUTPUT
  • 42. Lists Intro Operations on a list Functions/ methods  Lists Slicing;  Nested lists; finding the mean, maximum, minimum  linear search on list  counting the frequency Program to find the MEAN (AVERAGE) of all the elements of the list CONTENTS OUTPUT
  • 43. CONTENTS Lists Intro Operations on a list Functions/ methods  Lists Slicing;  Nested lists; finding the mean, maximum, minimum  linear search on list  counting the frequency OUTPUT Program to search an element in the List (LINEAR SEARCH)
  • 44. CONTENTS Lists Intro Operations on a list Functions/ methods  Lists Slicing;  Nested lists; finding the mean, maximum, minimum  linear search on list  counting the frequency OUTPUT Program to count frequency (/no. of times of occurrence) of an element in the List (FREQUENCY COUNT)
  • 45. Bibliograhy and References • Google • Wikipedia • XI Computer Science , By Sumita Arora, Dhanpat Rai Publication 2020 Edition • XI Informatics Practices , By Sumita Arora, Dhanpat Rai Publication 2020 Edition
  • 46. Programming is an ART…. Add your colours to it and make your own