Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Test 3A

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Choose the correct option with respect to Python.

a)

Both tuples and lists are immutable.

b)

Tuples are immutable while lists are mutable.

c)

Both tuples and lists are mutable.

d)

Tuples are mutable while lists are immutable.

2.

 

What will be the output of below Python code?

tuple1=(5,1,7,6,2)

tuple1.pop(2)

print(tuple1)

a)

(5,1,6,2)

b)

(5,1,7,6)

c)

(5,1,7,6,2)

d)

Error

3.

What will be the output of below Python code?

tuple1=(2,4,3)

tuple3=tuple1*2

print(tuple3)

a)

(4,8,6)

b)

(2,4,3,2,4,3)

c)

(2,2,4,4,3,3)

d)

Error

4.

What will be the output of below Python code?

tupl=("annie","hena","sid")

print(tupl[-3:0])

a)

("annie")

b)

()

c)

None

d)

Error as slicing is not possible in tuple.

5.

Which of the following options will not result in an error when performed on tuples in Python where tupl=(5,2,7,0,3)?

a)

tupl[1]=2

b)

tupl.append(2)

c)

tupl1=tupl+tupl

d)

tupl.sort()

6.

What will be the output of below Python code?

tupl=()

tupl1=tupl*2

print(len(tupl1))

a)

0

b)

2

c)

1

d)

Error as tuple object has no attribute to len

7.

What will be the output of below Python code?

tupl=([2,3],"abc",0,9)

tupl[0][1]=1

print(tupl)

a)

([2,3],"abc",0,9)

b)

([1,3],"abc",0,9)

c)

([2,1],"abc",0,9)

d)

Error

8.

Which of the following two Python codes will give same output?

(i) print(tupl[:-1])

(ii) print(tupl[0:5])

(iii) print(tupl[0:4])

(iv) print(tupl[-4:])

a)

i, ii

b)

ii, iv

c)

i, iv

d)

i, iii

9.

Which of the following is not a function of the tuple?

a)

max()

b)

min()

c)

count()

d)

update()

10.

Find the output of the given Python program?

t = (5,4,3,2,1)

x = sum(t,2)

print(x)

a)

15

b)

17

c)

30

d)

Error