Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Lesson 20 - Set

Total questions: 10

Worksheet time: 20mins

Name
Class
Date
1.

What will be the output of the following program ?

x={5,4,3,2,1}

print(x[0])

a)

5

b)

4

c)

2

d)

Error

2.

How many times the ‘hii’ will be printed ?

a)

2

b)

10

c)

3

d)

12

3.

What will be the output of the following program ?

a)

2

b)

6

c)

3

d)

5

4.

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)

a)

{2,3,5,6}

b)

{2,5,3,2}

c)

{1,2,3,4,5}

d)

error

5.

What will be the output of the following code ?

s={10,20,30)

t={20,30,40}

s=s.union(t)

print(s)

a)

{10,20,30,40}

b)

{20,30}

c)

{20,30,40}

d)

none

6.

What will be the output of following code ?

s=[1,2,3,4,5,2,4,1]

t=set(s)

print(t)

a)

{1,2,3,4,5}

b)

{1,2,3,4,5,2,4,1}

c)

{1,2,4}

d)

none

7.

Can you change the elements of the set ?

a)

yes

b)

no

c)

can't say

d)

may or may not be

8.

what will be the output of the following statement ?

a)

1

b)

0

c)

7

d)

Code will give an error

9.

What will be the output of the following code ?

a = {1,2,3,}

a.add(4)

print(a)

a)

{1,2,3,4}

b)

{1,2,3}

c)

{4,1,2,5}

d)

none

10.

which function is used to delete all the elements of the set ?

a)

delete()

b)

pop()

c)

clear()

d)

remove()