0% found this document useful (0 votes)
27 views2 pages

Python 08

The document outlines a practical exercise involving set operations in Python. It demonstrates adding and removing elements, performing set intersection, union, difference, and symmetric difference, as well as finding the maximum, minimum, and length of a set. The outputs of these operations are also printed for verification.

Uploaded by

yashmahajan4433
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)
27 views2 pages

Python 08

The document outlines a practical exercise involving set operations in Python. It demonstrates adding and removing elements, performing set intersection, union, difference, and symmetric difference, as well as finding the maximum, minimum, and length of a set. The outputs of these operations are also printed for verification.

Uploaded by

yashmahajan4433
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

Practical 8

1.
s1={1,2,3,4,5}
print("SET1=",s1)
s1.add(8)
print("Add",s1)
s1.remove(8)
print("Remove",s1)
output:

s1={1,2,3,4,5}
s2={4,5,6,7,8}
print("SET1=",s1)
print("SET2",s2)
print("INTERSACTION=",set.intersection(s1,s2))
print("UNION=",set.union(s1,s2))
print("DIFFERANCE=",set.difference(s1,s2))
print("SYMM DIFF=",set.symmetric_difference(s1,s2))
s1.clear
print(s1)
3.
s1={1,2,3,4,5}
print("SET1=",s1)
print("MAX=",max(s1))
print("MIN=",min(s1))
output:

4.
s1={1,2,3,4,5}
print("SET1=",s1)
print("LENGTH=",len(s1))
output:

You might also like