0% found this document useful (0 votes)
11 views6 pages

Experiment 6 Programs

Uploaded by

sangram.co10723
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Experiment 6 Programs

Uploaded by

sangram.co10723
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Name: Sangram S Supalkar

Branch: TYCO-B
Roll-84

Experiment-6
Q. 1 Sum of Items in list
l = [10,20,20,30,40]
sum = 0
for i in l:
sum += i
print("Sum of items in list : ",sum)
Output
Sum of items in list : 120
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

Q. 2 Multiplication of List
l = [4,5,6,3,5]
mul = 1
for i in l:
mul *= i
print("Multiplication of items in list : ",mul)
Output
Multiplication of items in list : 1800
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

Q. 3 Maximum from list


list1 = [20,40,50,60,30]
print("Maximum item in list ",list1,"=",max(list1))
Output
Maximum item in list [20, 40, 50, 60, 30] = 60

Q. 4 Smallest from list


list1 = [566,230,432,523,623,334]
print("Smallest item in list",list1,"=",min(list1))
Output
Smallest item in list [566, 230, 432, 523, 623, 334] = 230
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

Q. 5 Reverse List
l = [23,42,4,53,6,10]
revList = []
for i in range(len(l)-1,-1,-1):
revList.append(l[i])
print("Orignal List : ",l)
print("Reversed List : ",revList)
Output
Orignal List : [23, 42, 4, 53, 6, 10]
Reversed List : [10, 6, 53, 4, 42, 23]
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

Q. 6 Common Items from list


def commonItems(a,b):
a = set(a);
b = set(b)
c = a.intersection(b)
return c
l1 = [30,40,50,30,40,32,50,20,10]
l2 = [10,30,40,50,20,3,45]
common = list(commonItems(l1,l2))
print("List 1 : ",l1)
print("List 2 : ",l2)
print("Common items from both list : ",common)
Output
List 1 : [30, 40, 50, 30, 40, 32, 50, 20, 10]
List 2 : [10, 30, 40, 50, 20, 3, 45]
Common items from both list : [40, 10, 50, 20, 30]
Name: Sangram S Supalkar
Branch: TYCO-B
Roll-84

Q. 7 Even items from list


l = [23,42,4,53,6,10,68,48,88,50,5]
evenList = []
for i in l:
if i % 2 == 0:
evenList.append(i)
print("Orignal List :",l)
print("Even items from List :",evenList)
Output
Orignal List : [23, 42, 4, 53, 6, 10, 68, 48, 88, 50, 5]
Even items from List : [42, 4, 6, 10, 68, 48, 88, 50]

You might also like