(Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to check a given set has no elements in common with other given set. Sample Solution: Python Code: sn1 = {1,2,3} sn2 = {4,5,6} sn3 = {3} print(“Original sets:”) print(sn1) print(sn2) print(sn3) print(“Check sn1 set has no elements in common …
Day: March 6, 2021
(Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to check if a given set is superset of itself and superset of another given set. Sample Solution: Python Code: nums = {10,20,30,40,50} print(“Original set: “,nums) print(“If nums is superset of itself?”) print(nums.issuperset(nums)) num1 = {1, 2, 3, 4, 5, …
(Python Example for Citizen Data Scientist & Business Analyst) Write a Python program to check if two given sets have no elements in common. Sample Solution: Python Code: x = {1,2,3,4} y = {4,5,6,7} z = {8} print(“If two given sets have no elements in common”) print(“Compare x and y:”) print(x.isdisjoint(y)) print(“Compare x …