WorksheetsLesson 20 - Set
Total questions: 10
Worksheet time: 20mins
What will be the output of the following program ?
x={5,4,3,2,1}
print(x[0])
5
4
2
Error
How many times the ‘hii’ will be printed ?
2
10
3
12
What will be the output of the following program ?
2
6
3
5
What will be the output of the following program ?
s={2,5,3,6,3,7}
t={1,2,3,4,5,6}
s=s.intersection(t)
print(s)
{2,3,5,6}
{2,5,3,2}
{1,2,3,4,5}
error
What will be the output of the following code ?
s={10,20,30)
t={20,30,40}
s=s.union(t)
print(s)
{10,20,30,40}
{20,30}
{20,30,40}
none
What will be the output of following code ?
s=[1,2,3,4,5,2,4,1]
t=set(s)
print(t)
{1,2,3,4,5}
{1,2,3,4,5,2,4,1}
{1,2,4}
none
Can you change the elements of the set ?
yes
no
can't say
may or may not be
what will be the output of the following statement ?
1
0
7
Code will give an error
What will be the output of the following code ?
a = {1,2,3,}
a.add(4)
print(a)
{1,2,3,4}
{1,2,3}
{4,1,2,5}
none
which function is used to delete all the elements of the set ?
delete()
pop()
clear()
remove()
