The document contains a Python program to perform various operations on lists such as creating a list, accessing, updating, and deleting list items. It also contains programs to find the sum, product, largest, smallest, reverse of a list and common items between two lists. The program also selects even items from a given list.
The document contains a Python program to perform various operations on lists such as creating a list, accessing, updating, and deleting list items. It also contains programs to find the sum, product, largest, smallest, reverse of a list and common items between two lists. The program also selects even items from a given list.
The document contains a Python program to perform various operations on lists such as creating a list, accessing, updating, and deleting list items. It also contains programs to find the sum, product, largest, smallest, reverse of a list and common items between two lists. The program also selects even items from a given list.
Title: Write Python Program To Perform Following Operations On Lists :Create List ,Access List, Update List(Add Item, Remove Item),Delete List. list1=[10,20,30,40] list1[2]=18 print("Indexing Operation=>",list1) list1[1:2]=[20,20] print("After slicing operation=>>",list1) list1.append(60) print("Append method=>>",list1) list1.insert(3,77) print("Insert method=>>",list1) print("Accessing element using Index=>>",list1[4]) print("Accessing elements using Slicing=>>",list1[0:]) del list1[2] print("Deleting elements using DEL=>>",list1) print("Accessing element using Index=>>",list1[4]) print("Deleting element using POP()=>>",list1.pop()) print("Deleting element using REMOVE()=>>",list1.remove(10)) print("Current List=>>",list1) Practical No 6 Name: Shah Padmashree Ulhas Serial No:24 1.Write A Python Program To Sum All The Items In A List. list1=[10,20,30,40,50] print("Sum of elements in list",sum(list1))
2.Write A Python Program To Multiples All The Items In A List.
list1=[1,2,3,4,5] res=1 for i in list1: res=res*i print("Multiples all elements in list are:",res)
3.Write A Python Program To Get The Largest Number In The List.
list1=[10,20,30,40,50,60] print("Largest number in the list:",max(list1))
4.Write A Python Program To Get The Smallest Number In The List.
list1=[10,20,30,40,50,60] print("Smallest number in the list:",min(list1))
5.Write A Python Program To Reverse A List.
list1=[10,20,30,40,50,60] list1.reverse() print("Reverse of list1 is=",list1) 6.Write A Python Program To Find Common Items From Two Lists. list1=[10,20,30,40,50] list2=[10,20,30,40,50,60,70,80,90,100] list3=[] for i in range(len(list1)): if(list2.count(list1[i])>0 and list1[i] not in list3): list3.append(list1[i]) print("Comman Elements From list1 and list2=",list3) 7.Write A Python Program To Select The Even Items Of A List. list1=[10,20,30,40,50,60] print("List Elements=",list1) for i in list1: if(i%2==0): print("Even Elements From List Are:",i)