wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

TEST PAPER-TUPLE

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the output of the following piece of code when executed in Python shell?

a=('Check')*3

a)

('Check','Check','Check')

b)

* Operator not valid for tuples

c)

('CheckCheckCheck')

2.

What is the output of the following

aTuple = (10, 20, 30, 40, 50, 60, 70, 80)

print(aTuple[:4:-1])

a)

(30,40,50)

b)

(20,30,40,50)

c)

(80,70,60)

d)

(80,60,40,30)

3.

Choose the correct way to access value 20 from the following tuple

aTuple = ("abc","Apple",[1,0,3,20])

a)

aTuple[1:2][1]

 

b)

aTuple[1:2](1)

 

c)

aTuple[2][3]

d)

 aTuple[1][3]

4.

What is the output of the following

aTuple = ("Yellow", 20.4, "Red")

a, b, c = aTuple

len(b) 

a)

4

b)

 Error

c)

3

5.

predict the output:

t=(20,30,10,23,45,87,11)

sorted(T,reverse=False)

print(t)

a)

Error

b)

(10,11,20,23,30,45,87)

c)

(87,45,30,23,20,11,10)

d)

(20,30,10,23,45,87,11)

6.

Select most suitable code to create a tuple with a single element:

a)

t=('a',)

b)

t=['a']

c)

t=('a')

7.

What will be the output of the following Python code?

t=(1,2,4,3)

t.sorted()

print(t)

a)

(1,2,3,4)

b)

(2,4,3,1)

c)

(4,3,2,1)

d)

(1,2,3,4)

8.

What will be the output of the following Python code?

t1 = (1, 2, 4, 3)

t2 = (1, 2, 3, 4)

t1 ==t2

a)

Error

b)

True

c)

None

d)

False

9.

What will be the output of the following Python code?

my_tuple = (1, 2, 3, 4)

my_tuple+=((5, 6, 7) ,)

print len(my_tuple)

a)

7

b)

5

c)

Error

d)

1

10.

Suppose t = (1, 2, 4, 3), which of the following is incorrect?

a)

print(t.sort())

b)

print(t[3])

c)

print(max(t))

d)

print(len(t))