SlideShare a Scribd company logo
1 of 16
Write simple Python program to perform
following operations on List:Create
list,Access list,update list(add and remove
item),delete list
PRACTICAL NO 6
1. When to used list
List is used to save a collection of values of same
type in a variable and list support indexing.
2. Describe various list function.
3. Write a syntax for a method to sort a list.
4.Write a syntax for a method to count occurences
of a list item in python.
5.How to concatenate list
 The '+' operator can be used to concatenate two
lists. It appends one list at the end of the other list
and results in a new list as output.
 Syntax
List3=List1+List2
6. Justify the statement “List are mutable”
 The value of any element inside the List can be
changed at any point of time.
 The Elements of the List are accessible with their
index value.The index always start with 0 and ends
with n-1,if the list contains n elements.
 Example
List1=[10,20,30,40]
List1[2]=50
print(List1)
Output
[10, 20, 50, 40]
7. Describe the use of pop operator in list
If we know the index of the element that we want to
delete ,then we can use pop statement.
For Example
list=[10,20,30,40]
list.pop(3)
print(list)
output
[10, 20, 30]
1. Write a python program to sum all the items in a
list.
l=[6,4,9,7,3]
sum=0
for i in l:
sum=sum+i
print("Sum of elements ",l," is ",sum)
Output
Sum of elements [6, 4, 9, 7, 3] is 29
2. Write a python program to multiplies all the items
in a list
l=[2,5,3,1]
sum=1
for i in l:
sum=sum*i
print("Multiplies of elements ",l," is ",sum)
Output
Multiplies of elements [2, 5, 3, 1] is 30
3. Write a program to get the largest number from
list
l=[2,6,98,7,67,1,9,54]
m=0
for i in l:
if(m<i):
m=i
print("LARGEST eLEMENT IN THE lIST=",m)
Output
LARGEST eLEMENT IN THE lIST= 98
4. Write a program to get the smallest number
from list
l=[2,6,98,7,67,1,9,54]
m=l[0]
for i in l:
if(m>i):
m=i
print("SMALLEST ELEMENT=",m)
Output
SMALLEST ELEMENT= 1
5. Write a program to reverse a list.
l1=[1,2,3,4,5]
print("Before reversing ",l1)
l1.reverse()
print("After reversing ",l1)
Output
Before reversing [1, 2, 3, 4, 5]
After reversing [5, 4, 3, 2, 1]
6. Write a program to find common items from two list
l1=[2,5,3,8,9]
l2=[4,1,2,6,8]
l=len(l1)
print("common elements ARE ")
for i in range(0,l):
for j in range(0,l):
if(l1[i]==l2[j]):
print(l1[i])
Output
common elements ARE
2
8
7. Write a program to select the even items of a list.
l=[3,2,5,6,4,8]
print("Are the even numbers from the list")
for i in l:
if(i%2==0):
print(i)
Output
Are the even numbers from the list
2
6
4
8
End

More Related Content

Similar to Python PRACTICAL NO 6 for your Assignment.pptx

Similar to Python PRACTICAL NO 6 for your Assignment.pptx (20)

Python data handling notes
Python data handling notesPython data handling notes
Python data handling notes
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Python list
Python listPython list
Python list
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdf
 
Python Data Types (1).pdf
Python Data Types (1).pdfPython Data Types (1).pdf
Python Data Types (1).pdf
 
Python list
Python listPython list
Python list
 
Module-2.pptx
Module-2.pptxModule-2.pptx
Module-2.pptx
 
The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184
 
Python PCEP Lists Collections of Data
Python PCEP Lists Collections of DataPython PCEP Lists Collections of Data
Python PCEP Lists Collections of Data
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
 
List in Python
List in PythonList in Python
List in Python
 
Python lists &amp; sets
Python lists &amp; setsPython lists &amp; sets
Python lists &amp; sets
 
Python list
Python listPython list
Python list
 
Lecture2.pptx
Lecture2.pptxLecture2.pptx
Lecture2.pptx
 
Lists
ListsLists
Lists
 
updated_list.pptx
updated_list.pptxupdated_list.pptx
updated_list.pptx
 
python.pptx
python.pptxpython.pptx
python.pptx
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Data type list_methods_in_python
Data type list_methods_in_pythonData type list_methods_in_python
Data type list_methods_in_python
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 

Python PRACTICAL NO 6 for your Assignment.pptx

  • 1. Write simple Python program to perform following operations on List:Create list,Access list,update list(add and remove item),delete list PRACTICAL NO 6
  • 2. 1. When to used list List is used to save a collection of values of same type in a variable and list support indexing.
  • 3. 2. Describe various list function.
  • 4. 3. Write a syntax for a method to sort a list.
  • 5. 4.Write a syntax for a method to count occurences of a list item in python.
  • 6. 5.How to concatenate list  The '+' operator can be used to concatenate two lists. It appends one list at the end of the other list and results in a new list as output.  Syntax List3=List1+List2
  • 7. 6. Justify the statement “List are mutable”  The value of any element inside the List can be changed at any point of time.  The Elements of the List are accessible with their index value.The index always start with 0 and ends with n-1,if the list contains n elements.  Example List1=[10,20,30,40] List1[2]=50 print(List1) Output [10, 20, 50, 40]
  • 8. 7. Describe the use of pop operator in list If we know the index of the element that we want to delete ,then we can use pop statement. For Example list=[10,20,30,40] list.pop(3) print(list) output [10, 20, 30]
  • 9. 1. Write a python program to sum all the items in a list. l=[6,4,9,7,3] sum=0 for i in l: sum=sum+i print("Sum of elements ",l," is ",sum) Output Sum of elements [6, 4, 9, 7, 3] is 29
  • 10. 2. Write a python program to multiplies all the items in a list l=[2,5,3,1] sum=1 for i in l: sum=sum*i print("Multiplies of elements ",l," is ",sum) Output Multiplies of elements [2, 5, 3, 1] is 30
  • 11. 3. Write a program to get the largest number from list l=[2,6,98,7,67,1,9,54] m=0 for i in l: if(m<i): m=i print("LARGEST eLEMENT IN THE lIST=",m) Output LARGEST eLEMENT IN THE lIST= 98
  • 12. 4. Write a program to get the smallest number from list l=[2,6,98,7,67,1,9,54] m=l[0] for i in l: if(m>i): m=i print("SMALLEST ELEMENT=",m) Output SMALLEST ELEMENT= 1
  • 13. 5. Write a program to reverse a list. l1=[1,2,3,4,5] print("Before reversing ",l1) l1.reverse() print("After reversing ",l1) Output Before reversing [1, 2, 3, 4, 5] After reversing [5, 4, 3, 2, 1]
  • 14. 6. Write a program to find common items from two list l1=[2,5,3,8,9] l2=[4,1,2,6,8] l=len(l1) print("common elements ARE ") for i in range(0,l): for j in range(0,l): if(l1[i]==l2[j]): print(l1[i]) Output common elements ARE 2 8
  • 15. 7. Write a program to select the even items of a list. l=[3,2,5,6,4,8] print("Are the even numbers from the list") for i in l: if(i%2==0): print(i) Output Are the even numbers from the list 2 6 4 8
  • 16. End