python Set Questions & Answers

Question 1: What will be the output of the following code?

s = set('Hello')
print(s)

Question 2: What will be the output of the following code?

s1={1,2,3,4,5}
s2={4,5,6,7,8}
print(s1-s2)

Question 3: What will be the output of the following program?

s1={1,2,3,4,5}
s2={4,5,6,7,8}
print(s1|s2)
ADVERTISEMENT

Question 4: What will be the output of the following code?

>>> emp = {} 
>>> type(emp)

Question 5: How to convert a tuple to a set object?