Raunakmalkani - 20BIT032 - Assignment On Set
Raunakmalkani - 20BIT032 - Assignment On Set
Raunakmalkani - 20BIT032 - Assignment On Set
UID:- 20BIT032
ASSIGNEMENT ON SETS
Aim 1 : - WAP to demonstrate the use of copy(), isdisjoint(), issubset(),
issuperset(), difference_update(), symmetric_difference_update_()
CODE:
x = {"Rohan", "Harry", "Rhythm"}
y = x.copy()
print("Copied set ", y)
OUTPUT:-
Aim 2:- WAP to convert set into a list, tuple and string
CODE:
my_set = {'Rhythm', 'Harry', 'Rohan'}
print("Set Before Conversion", my_set)
# List
s = list(my_set)
print("\nAfter the conversion")
print("The datatype of s : " + str(type(s)))
print("Contents of s : ", s)
# tuple
s = tuple(my_set)
print("\nAfter the conversion")
print("The datatype of s : ", (type(s)))
print("Contents of s : ", s)
# String
s = str(my_set)
print("\nAfter the conversion")
print("The datatype of s : ", (type(s)))
print("Contents of s : ", s)
OUTPUT:-
Aim 3:- WAP to find maximum and minimum value in a set
CODE:-
setn = {5, 10, 3, 15, 2, 20}
print("Original set elements:")
print(setn)
print("\nMaximum value of the said set:")
print(max(setn))
print("\nMinimum value of the said set:")
print(min(setn))
OUTPUT:-
Aim 4:- WAP to check if 2 sets have any elements in common. If yes,
display the common elements.
CODE:-
def common_member(a, b):
a_set = set(a)
b_set = set(b)
a = [6, 7, 8, 1, 2]
b = [5, 6, 7, 8, 9]
print(a)
print(b)
common_member(a, b)
OUTPUT:-
Aim 5:- WAP to find the elements in a given set that are not in another
set.
CODE:-
sn1 = {1,2,3,4,5}
sn2 = {4,5,6,7,8}
print("Original sets:")
print(sn1)
print(sn2)
print("Difference:")
print(sn1-sn2)
OUTPUT:-
def ispangram(string):
return set(string.lower()) >= alphabet
string = "The quick brown fox jumps over the lazy dog"
print(string)
if (ispangram(string) == True):
print("\n It is a pangram")
else:
print("No")
OUTPUT:-