SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
T.Priya
Assistant Professor
 Lists are used to store multiple items or values in a single variable.
 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 list are mutable, ordered, changeable, and allow duplicate
values. we can change their elements after forming.
 Lists are one of 4 built-in data types the other 3 are Tuple, Set and
Dictionary, all with different qualities and usage.
 Lists are created using square brackets [ ] and separated by
commas.
 List items are indexed, the first item has index [0], the second item
has index [1] etc.
List Introduction:
Syntax:
list [iterable]
Example for python list:
>>> list=['a','b','c']
>>> print(list)
Output:
['a', 'b', 'c']
>>>
Example 2:
>>> list=[2,3,4,5,6]
>>> print(list)
O/P [2, 3, 4, 5, 6]
A list can contain different data types:
>>> list=["rakshita",2,"sweatha",1]
>>> print(list)
O/P ['rakshita', 2, 'sweatha', 1]
Access value in list:
There are different ways to accessing the list in python (index
and value)
Example (index value)
•
>>> list=["CS","CA","MSC"]
>>> print(list[0])
CS
>>> print(list[1])
CA
>>> print(list[2])
MSC
list.index() Return the index
value
Ex:
>>> list=["CS","CA","MSC"]
>>> list.index("CA")
O/P
1
Adding an item in the list:
append()  The append() method adds an item at the end of
the list.
>>> list.append("AI&DS")
>>> print(list)
O/P
['CS', 'CA', 'MSC', 'AI&DS']
Insert  The insert() method to add an element at the
specified index.
>>> list.insert(2,"MCA")
>>> print(list)
['CS', 'CA', 'MCA', 'MSC', 'AI&DS']
Nested List:
In order to create a nested list, you can simply use
square brackets [] to enclose one or more lists inside
another list.
Example 1:
>>>
list=[['cs','ca'],[2,4],[True,False]]
>>> print(list)
O/P
[['cs', 'ca'], [2, 4], [True, False]]
Example 2:
>>> list1=["cs","ca"]
>>> list2=["msc"]
>>> list3=[list1,list2]
>>> list3
O/P
[['cs', 'ca'], ['msc']]
Basic Operation in list & List Methods :
There are many different types of operations that
you can perform on Python lists, including:
1. Append 2. Insert 3. Length 4.Sort
5. Indexing 6. Delete 7. Pop 8. Concatenation
9. Reverse 10. Extend
1. Append:
The append() method adds an item at the end of the list.
Example:
>>> list=["CS","CA","MSC"]
>>> print(list)
O/P
['CS', 'CA', 'MSC']
>>> list.append("AI&DS")
>>> print(list)
O/P
['CS', 'CA', 'MSC', 'AI&DS']
2.Insert:
The insert() method to add an element at the specified
index.
Example:
>>> list=["CS","CA","MSC"]
>>> print(list)
O/P
['CS', 'CA', 'MSC']
>>> list.insert(2,"MCA")
>>> print(list)
O/P
['CS', 'CA', 'MCA', 'MSC']
3.Length:
Python len() is used to get the length of the list.
Example:
4. Sort:
The list elements can be sorted either ascending or descending.
Example:
>>> list=[]
>>> print(len(list))
O/P  0
>>> list=["CS","CA","MSC"]
>>> print(len(list))
O/P  3
>>>
a=["sweatha","priya","rakshita"]
>>> a.sort()
>>> print(a)
O/P
['priya', 'rakshita', 'sweatha']
5. Indexing:
index() is a built-in Python function that Return the index value.
Example:
6.Delete:
Using the remove function, we can easily delete a list element.
Example:
>>>list=["CS","CA","MSC"]
>>> list.index("CA")
O/P
1
>>>list=["CS","CA","MSC"]
>>> list.remove("CS")
>>> print(list)
O/P
['CA', 'MSC']
7. Pop:
The pop() function can also be used to delete and return a list
element (index value).
Example:
8. Concatenation:
Using the ‘+’ operator, we can easily concatenate two lists.
(Concatenation is equivalent to appending two lists).
Example:
>>>
a=["sweatha","priya","rakshita"]
>>> a.pop(1)
'priya'
>>> print(a)
O/P ['sweatha', 'rakshita']
>>> list1=["cs","ca"]
>>> list2=["msc","mca"]
>>> print(list1+list2)
O/P
['cs', 'ca', 'msc', 'mca']
9. Reverse:
Reverses the order of the elements in the list.
Example:
10. Extend:
Extend () method can be used to add more than one element at the
end of a list.
Example:
>>> list=['a','b','c','d']
>>> list.reverse()
>>> print(list)
O/P
['d', 'c', 'b', 'a']
>>> ss=['cs','ca']
>>> ss.extend(['msccs'])
>>> print(ss)
O/P
['cs', 'ca', 'msccs']
11. Max & Min:
The method used to find the minimum element in the list, and
the maximum element in the list.
Example:
>>> s1=[56,76,34,90,46]
>>> print(max(s1))
90
>>> s1=[56,76,34,90,46]
>>> print(min(s1))
34
Python List.ppt

More Related Content

What's hot (20)

PPTX
Looping Statements and Control Statements in Python
PriyankaC44
 
PDF
Python list
Mohammed Sikander
 
PPTX
Datastructures in python
hydpy
 
PPTX
Strings in c++
Neeru Mittal
 
PDF
Datatypes in python
eShikshak
 
PPTX
Tuple in python
Sharath Ankrajegowda
 
PPTX
Python strings presentation
VedaGayathri1
 
PDF
Strings in python
Prabhakaran V M
 
PPT
Arrays
SARITHA REDDY
 
PPTX
Data types in python
RaginiJain21
 
PDF
Python programming : Strings
Emertxe Information Technologies Pvt Ltd
 
PPTX
Control statements in c
Sathish Narayanan
 
PPTX
Loops in Python
AbhayDhupar
 
PPTX
Data Structures in Python
Devashish Kumar
 
PPTX
C string
University of Potsdam
 
PPTX
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
PPT
File handling in c
David Livingston J
 
PPTX
Sorting in python
Simplilearn
 
Looping Statements and Control Statements in Python
PriyankaC44
 
Python list
Mohammed Sikander
 
Datastructures in python
hydpy
 
Strings in c++
Neeru Mittal
 
Datatypes in python
eShikshak
 
Tuple in python
Sharath Ankrajegowda
 
Python strings presentation
VedaGayathri1
 
Strings in python
Prabhakaran V M
 
Data types in python
RaginiJain21
 
Python programming : Strings
Emertxe Information Technologies Pvt Ltd
 
Control statements in c
Sathish Narayanan
 
Loops in Python
AbhayDhupar
 
Data Structures in Python
Devashish Kumar
 
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
File handling in c
David Livingston J
 
Sorting in python
Simplilearn
 

Similar to Python List.ppt (20)

PPTX
Python for Beginners(v3)
Panimalar Engineering College
 
PPTX
Python lists
nuripatidar
 
PPT
UNIT 4 PY.ppt - DATA STRUCTURE IN PYTHON
drkangurajuphd
 
PDF
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
Guru Nanak Technical Institutions
 
PPTX
Python list
ArchanaBhumkar
 
PPTX
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
DeepakRattan3
 
PPTX
Python for the data science most in cse.pptx
Rajasekhar364622
 
PPTX
Brief Explanation On List and Dictionaries of Python
nikhita4775
 
PPTX
Chapter 15 Lists
Praveen M Jigajinni
 
PPTX
Python Lecture 8
Inzamam Baig
 
PPTX
Lecture2.pptx
Sakith1
 
PPTX
Python list tuple dictionary .pptx
miteshchaudhari4466
 
PPTX
updated_list.pptx
Koteswari Kasireddy
 
PDF
8 python data structure-1
Prof. Dr. K. Adisesha
 
PPTX
Lists.pptx
Yagna15
 
PPTX
List_tuple_dictionary.pptx
ChandanVatsa2
 
PDF
Lists and its functions in python for beginners
Mohammad Usman
 
PDF
The Ring programming language version 1.9 book - Part 29 of 210
Mahmoud Samir Fayed
 
Python for Beginners(v3)
Panimalar Engineering College
 
Python lists
nuripatidar
 
UNIT 4 PY.ppt - DATA STRUCTURE IN PYTHON
drkangurajuphd
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
Guru Nanak Technical Institutions
 
Python list
ArchanaBhumkar
 
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
DeepakRattan3
 
Python for the data science most in cse.pptx
Rajasekhar364622
 
Brief Explanation On List and Dictionaries of Python
nikhita4775
 
Chapter 15 Lists
Praveen M Jigajinni
 
Python Lecture 8
Inzamam Baig
 
Lecture2.pptx
Sakith1
 
Python list tuple dictionary .pptx
miteshchaudhari4466
 
updated_list.pptx
Koteswari Kasireddy
 
8 python data structure-1
Prof. Dr. K. Adisesha
 
Lists.pptx
Yagna15
 
List_tuple_dictionary.pptx
ChandanVatsa2
 
Lists and its functions in python for beginners
Mohammad Usman
 
The Ring programming language version 1.9 book - Part 29 of 210
Mahmoud Samir Fayed
 
Ad

Recently uploaded (20)

PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PPTX
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Distribution reservoir and service storage pptx
dhanashree78
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Ad

Python List.ppt

  • 2.  Lists are used to store multiple items or values in a single variable.  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 list are mutable, ordered, changeable, and allow duplicate values. we can change their elements after forming.  Lists are one of 4 built-in data types the other 3 are Tuple, Set and Dictionary, all with different qualities and usage.  Lists are created using square brackets [ ] and separated by commas.  List items are indexed, the first item has index [0], the second item has index [1] etc. List Introduction:
  • 3. Syntax: list [iterable] Example for python list: >>> list=['a','b','c'] >>> print(list) Output: ['a', 'b', 'c'] >>>
  • 4. Example 2: >>> list=[2,3,4,5,6] >>> print(list) O/P [2, 3, 4, 5, 6] A list can contain different data types: >>> list=["rakshita",2,"sweatha",1] >>> print(list) O/P ['rakshita', 2, 'sweatha', 1]
  • 5. Access value in list: There are different ways to accessing the list in python (index and value) Example (index value) • >>> list=["CS","CA","MSC"] >>> print(list[0]) CS >>> print(list[1]) CA >>> print(list[2]) MSC list.index() Return the index value Ex: >>> list=["CS","CA","MSC"] >>> list.index("CA") O/P 1
  • 6. Adding an item in the list: append()  The append() method adds an item at the end of the list. >>> list.append("AI&DS") >>> print(list) O/P ['CS', 'CA', 'MSC', 'AI&DS'] Insert  The insert() method to add an element at the specified index. >>> list.insert(2,"MCA") >>> print(list) ['CS', 'CA', 'MCA', 'MSC', 'AI&DS']
  • 7. Nested List: In order to create a nested list, you can simply use square brackets [] to enclose one or more lists inside another list. Example 1: >>> list=[['cs','ca'],[2,4],[True,False]] >>> print(list) O/P [['cs', 'ca'], [2, 4], [True, False]] Example 2: >>> list1=["cs","ca"] >>> list2=["msc"] >>> list3=[list1,list2] >>> list3 O/P [['cs', 'ca'], ['msc']]
  • 8. Basic Operation in list & List Methods : There are many different types of operations that you can perform on Python lists, including: 1. Append 2. Insert 3. Length 4.Sort 5. Indexing 6. Delete 7. Pop 8. Concatenation 9. Reverse 10. Extend
  • 9. 1. Append: The append() method adds an item at the end of the list. Example: >>> list=["CS","CA","MSC"] >>> print(list) O/P ['CS', 'CA', 'MSC'] >>> list.append("AI&DS") >>> print(list) O/P ['CS', 'CA', 'MSC', 'AI&DS']
  • 10. 2.Insert: The insert() method to add an element at the specified index. Example: >>> list=["CS","CA","MSC"] >>> print(list) O/P ['CS', 'CA', 'MSC'] >>> list.insert(2,"MCA") >>> print(list) O/P ['CS', 'CA', 'MCA', 'MSC']
  • 11. 3.Length: Python len() is used to get the length of the list. Example: 4. Sort: The list elements can be sorted either ascending or descending. Example: >>> list=[] >>> print(len(list)) O/P  0 >>> list=["CS","CA","MSC"] >>> print(len(list)) O/P  3 >>> a=["sweatha","priya","rakshita"] >>> a.sort() >>> print(a) O/P ['priya', 'rakshita', 'sweatha']
  • 12. 5. Indexing: index() is a built-in Python function that Return the index value. Example: 6.Delete: Using the remove function, we can easily delete a list element. Example: >>>list=["CS","CA","MSC"] >>> list.index("CA") O/P 1 >>>list=["CS","CA","MSC"] >>> list.remove("CS") >>> print(list) O/P ['CA', 'MSC']
  • 13. 7. Pop: The pop() function can also be used to delete and return a list element (index value). Example: 8. Concatenation: Using the ‘+’ operator, we can easily concatenate two lists. (Concatenation is equivalent to appending two lists). Example: >>> a=["sweatha","priya","rakshita"] >>> a.pop(1) 'priya' >>> print(a) O/P ['sweatha', 'rakshita'] >>> list1=["cs","ca"] >>> list2=["msc","mca"] >>> print(list1+list2) O/P ['cs', 'ca', 'msc', 'mca']
  • 14. 9. Reverse: Reverses the order of the elements in the list. Example: 10. Extend: Extend () method can be used to add more than one element at the end of a list. Example: >>> list=['a','b','c','d'] >>> list.reverse() >>> print(list) O/P ['d', 'c', 'b', 'a'] >>> ss=['cs','ca'] >>> ss.extend(['msccs']) >>> print(ss) O/P ['cs', 'ca', 'msccs']
  • 15. 11. Max & Min: The method used to find the minimum element in the list, and the maximum element in the list. Example: >>> s1=[56,76,34,90,46] >>> print(max(s1)) 90 >>> s1=[56,76,34,90,46] >>> print(min(s1)) 34