Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
21 views1 page

Practical No 06

The document outlines a Python program that performs various operations on lists, including finding the smallest and largest numbers, summing items, multiplying elements, reversing a list, and identifying common and even elements. It provides code snippets and outputs for each operation. The program uses two lists, list1 and list2, to demonstrate these functionalities.

Uploaded by

Dhanashri Karad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

Practical No 06

The document outlines a Python program that performs various operations on lists, including finding the smallest and largest numbers, summing items, multiplying elements, reversing a list, and identifying common and even elements. It provides code snippets and outputs for each operation. The program uses two lists, list1 and list2, to demonstrate these functionalities.

Uploaded by

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

Practical No 06

Title: Write a Python program to perform operations on list.


Class: TYCM-WIN Batch: A Roll No: 16
# 4) small no in list
list1= [10,20,60,40] small_no = min(list1)
list2= [20,60,75,80]
print("Smallest no in list",small_no)
#1)sum of items present in a list small=list2[0]
s = sum(list1) for l in list2:
print ("sum of all the items in a list using if small<l:
function :",s) l=small
print ("Smallest no in list",small)
total=0 Output:
for l in list1: Smallest no in list 10
total+=l Smallest no in list 20
print ("sum of all the items in a list without
using function :",total) #reverse the list
list2.reverse()
Output: print ("Elements of list 2 in reverse:",list2)
sum of all the items in a list using function Output:
: 130 Elements of list 2 in reverse: [80, 75, 60,
sum of all the items in a list without using 20]
function : 130

# 2)multiplies items in the list #common item between two list


mul=1 common_element=[]
for i in list1: for i in list1:
mul*=i if i in list2:
#print(mul) common_element.append(i)
print("Multiplication of elemnnts present
in a list1",mul) print( "Common
element:",common_element)
Output: Output:
Multiplication of elemnnts present in a Common element: [20, 60]
list1 480000
#find even items of the list
# 3) largest no in a list even=[]
larger_no=max(list1) for i in list2:
print("Largest no present in a list using if i%2==0:
function:",larger_no) even.append(i)
print ("even no in list2:",even)
larger=list1[0] Output:
for l in list1: even no in list2: [80, 60, 20]
if l>larger:
larger=l
print("largest element in list:",larger)
Output:
Largest no present in a list using function:
60
largest element in list: 60

You might also like