Python Set MCQs

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)

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?

Question 6: Set is:

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

s={1,2,3 }
s[0]=10
print(s)

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

myset={1,2,3 }
for i in myset:
    print(i)