Practical - 7
Practical - 7
dic1={1:10, 2:20}
dic2={3:30, 4:40}
dic3={5:50,6:60}
dic4 = {}
for d in (dic1, dic2, dic3): dic4.update(d)
print(dic4)
Output
# Driver Code
dic1 = {'val1': 10, 'val2':20, 'val3':30}
key1 = 'val3'
print(dic1)
ck(dic1, key1)
key1 = 'val5'
ck(dic1, key1)
Output
Output
print({**dict1, **dict2})
print(dict3)
Output
v= sal.values()
max1 = max(v)
min1 = min(v)
print("Maximum :",max1)
print("Minimum :",min1)
Output
Maximum : 8500
Minimum : 5000
6.Write a Python program to create set difference, Union and intersection
set1 = {9, 2, 4, 6, 8}
set2 = {7, 2, 3, 4, 5}
print("Union :", set1 | set2)
print("Intersection :",set1 & set2)
print("Difference :", set1 - set2)
print("Symmetric difference :", set1 ^ set2)
Output
Union : {2, 3, 4, 5, 6, 7, 8, 9}
Intersection : {2, 4}
Difference : {8, 9, 6}
Symmetric difference : {3, 5, 6, 7, 8, 9}
7.Write a Python program to check if two given sets have no elements in common
x = {11,22,31,45}
y = {44,51,22,74}
z = {84}
print("Original set elements:")
print(x)
print(y)
print(z)
print("\nConfirm two given sets have no element(s) in common:")
print("\nCompare x and y:")
print(x.isdisjoint(y))
print("\nCompare x and z:")
print(z.isdisjoint(x))
print("\nCompare y and z:")
print(y.isdisjoint(z))
Compare x and y:
False
Compare x and z:
True
Compare y and z:
True