SlideShare a Scribd company logo
3
Most read
5
Most read
11
Most read
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

PDF
List , tuples, dictionaries and regular expressions in python
PDF
Python set
PPSX
Modules and packages in python
PPTX
Stacks IN DATA STRUCTURES
PDF
Function overloading ppt
PPT
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
PPTX
Programming in c Arrays
PPTX
Python-Encapsulation.pptx
List , tuples, dictionaries and regular expressions in python
Python set
Modules and packages in python
Stacks IN DATA STRUCTURES
Function overloading ppt
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Programming in c Arrays
Python-Encapsulation.pptx

What's hot (20)

PPTX
Searching & Algorithms IN DATA STRUCTURES
PPT
Python List.ppt
PPTX
List in python
PDF
Html frames
PPTX
Python-Inheritance.pptx
PPTX
Pointers in c
PPTX
Introduction to matplotlib
PPTX
Chapter 14 strings
PPT
Linked list
PPTX
Stack and queue
PDF
Python Variable Types, List, Tuple, Dictionary
PPTX
PPTX
Pointer arithmetic in c
DOCX
Practical file on web technology(html)
PPTX
Html form tag
PDF
Linear search
PPS
Wrapper class
PPTX
Insertion in singly linked list
ODP
Searching & Algorithms IN DATA STRUCTURES
Python List.ppt
List in python
Html frames
Python-Inheritance.pptx
Pointers in c
Introduction to matplotlib
Chapter 14 strings
Linked list
Stack and queue
Python Variable Types, List, Tuple, Dictionary
Pointer arithmetic in c
Practical file on web technology(html)
Html form tag
Linear search
Wrapper class
Insertion in singly linked list
Ad

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

PPTX
Python for the data science most in cse.pptx
DOCX
Python Materials- Lists, Dictionary, Tuple
PPTX
lists8.pptx of chapter 12 IP Basic Python
PDF
List in Python Using Back Developers in Using More Use.
PDF
Unit 1-Part-4-Lists, tuples and dictionaries.pdf
PPTX
Unit 4 python -list methods
PDF
The Ring programming language version 1.6 book - Part 24 of 189
PPTX
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
PPTX
Introduction To Programming with Python-4
PDF
The Ring programming language version 1.10 book - Part 30 of 212
PPTX
Python _dataStructures_ List, Tuples, its functions
PDF
The Ring programming language version 1.8 book - Part 27 of 202
PPTX
List In Python Programming. The linked list
PDF
The Ring programming language version 1.9 book - Part 29 of 210
PPTX
institute of techonolgy and education tr
PPTX
PROBLEM SOLVING AND PYTHON PROGRAMMING PPT
PDF
Python data handling notes
PPTX
Chapter 15 Lists
PDF
Python list
Python for the data science most in cse.pptx
Python Materials- Lists, Dictionary, Tuple
lists8.pptx of chapter 12 IP Basic Python
List in Python Using Back Developers in Using More Use.
Unit 1-Part-4-Lists, tuples and dictionaries.pdf
Unit 4 python -list methods
The Ring programming language version 1.6 book - Part 24 of 189
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
Introduction To Programming with Python-4
The Ring programming language version 1.10 book - Part 30 of 212
Python _dataStructures_ List, Tuples, its functions
The Ring programming language version 1.8 book - Part 27 of 202
List In Python Programming. The linked list
The Ring programming language version 1.9 book - Part 29 of 210
institute of techonolgy and education tr
PROBLEM SOLVING AND PYTHON PROGRAMMING PPT
Python data handling notes
Chapter 15 Lists
Python list
Ad

Recently uploaded (20)

PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Types and Its function , kingdom of life
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
master seminar digital applications in india
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Cell Structure & Organelles in detailed.
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharma ospi slides which help in ospi learning
Cell Types and Its function , kingdom of life
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
master seminar digital applications in india
A systematic review of self-coping strategies used by university students to ...
Microbial disease of the cardiovascular and lymphatic systems
human mycosis Human fungal infections are called human mycosis..pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Weekly quiz Compilation Jan -July 25.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Chinmaya Tiranga quiz Grand Finale.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
RMMM.pdf make it easy to upload and study
Computing-Curriculum for Schools in Ghana
Cell Structure & Organelles in detailed.
Supply Chain Operations Speaking Notes -ICLT Program

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