[go: up one dir, main page]

0% found this document useful (0 votes)
13 views3 pages

Practical 8

The document contains Python programs demonstrating various set operations, including creating a set, adding and removing items, performing intersections, unions, differences, and symmetric differences of sets, clearing a set, finding maximum and minimum values, and determining the length of a set. Each program includes sample sets and corresponding print statements to display the results of the operations performed. The output for each operation is expected but not provided in the document.

Uploaded by

Kailas Rahane
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)
13 views3 pages

Practical 8

The document contains Python programs demonstrating various set operations, including creating a set, adding and removing items, performing intersections, unions, differences, and symmetric differences of sets, clearing a set, finding maximum and minimum values, and determining the length of a set. Each program includes sample sets and corresponding print statements to display the results of the operations performed. The output for each operation is expected but not provided in the document.

Uploaded by

Kailas Rahane
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/ 3

Practical 8

1.Write a python program to create a set ,add members in a set and removeone item from
set.

a={1,2,3,4,5}

print("set=",a)

a.add(6)

print("Adding 6 in set a¥n",a)

a.remove(1)

print("Removing 1 in set a¥n",a)

output:

2.Write a python program to perform the following operations on set: theintersection of sets,
the union of sets, set difference, symmetric difference,clear a set.
s1={1,2,3,4,5,6,7}

s2={5,6,7,8,9,10}

print("s1 =", s1)

print("s2 =", s2)

print("intersections of sets",s1 & s2)

print("Union of sets",s1 | s2)

print("Difference of sets (s1-s2)=",s1-s2)


print("Symmetric difference =",s1^s2)

s1.clear()

print("S1 is cleared=",s1)

output:

3.Write a python program to find maximum and minimum value in a set.


s1={1,2,3,4,5}

print("set=",s1)

print("Maximum value=",max(s1))

print("Minimum value=",min(s1))

output:

4.Write a python program to find length of a set.


set={0,1,2,3,4,5}

print("set=",set)

print("length=",len(set))

output:

You might also like