You are on page 1of 3

Exp6_Pr1_34: Write a Python program to sum all the items in a list.

list=[10,20,30,40,50]
sum=0 for i in list:
sum+=i
print("Addition:-",sum)

Output:

Exp6_Pr2_34: Write a Python program to multiplies all the items in a list.

list=[1,2,3,4,5]
m=1 for i
in list:
m*=i
print("Multiplication:-",m)

Output:

Exp6_Pr3_34: Write a Python program to get the largest number from a list.

list=[10,20,30,40,50]
large=list[0] for i in
list: if(large<i):
large=i
print("Largest element:-",large)

Output:
Exp6_Pr4_34: Write a Python program to get the smallest number from a list.

list=[10,20,30,40,50,14,8,74]
small=list[0] for i in list:
if(small>i): small=i
print("Smallest element:-",small)

Output:

Exp6_Pr5_34: Write a Python program to reverse a list.

list=[10,20,30,40,50,14,8,74]
rev=[] ind=-1 i=0 for i in
list: rev.insert(ind,i)
ind-=1
print("Reverse list:-",rev)

Output:

Exp6_Pr6_34: Write a Python program to find common items from two lists.

list1=[10,20,30,40,50,14,8,74]
list2=[9,10,11,15,20,22,8,40]
clist=[] i=0 for i in list1: if((i in
list2) and (i not in clist)):
clist.append(i)
print("Common Elements:-",clist)

Output:

Exp6_Pr7_34: Write a Python program to select the even items of a list.


list=[10,27,30,40,59,8,75] i=0
print("Even Elements:-")
for i in list: if(i
%2==0): print(i)
Output:

You might also like