Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Sequences

Total questions: 10

Worksheet time: 3mins

Name
Class
Date
1.

What will be the output of the following Python statement?

>>>"a"+"bc"

a)

a

b)

bc

c)

bca

d)

abc

2.

What will be the output of the following Python code?

>>> str1 = 'hello'

>>> str2 = ','

>>> str3 = 'world'

>>> str1[-1:]

a)

olleh

b)

hello

c)

h

d)

o

3.

Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?

a)

5

b)

4

c)

None

d)

Error

4.

What will be the output of the following Python code?

>>>names = ['Amir', 'Bear', 'Charlton', 'Daman'] >>>print(names[-1][-1])

a)

A

b)

Daman

c)

Error

d)

n

5.

What will be the output of the following Python code snippet?


print([i.lower() for i in "HELLO"])

a)

[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

b)

‘hello’

c)

[‘hello’]

d)

hello

6.

What will be the output of the following Python code snippet?

>>> d = {"john":40, "peter":45}

>>> "john" in d

a)

True

b)

False

c)

None

d)

Error

7.

What will be the output of the following Python code snippet?

>>> d1 = {"john":40, "peter":45}

>>> d2 = {"john":466, "peter":45}

>>> d1 > d2

a)

True

b)

False

c)

Error

d)

None

8.

What will be the output of the following Python code?


>>>t = (1, 2, 4, 3, 8, 9)

>>>[t[i] for i in range(0, len(t), 2)]

a)

[2,3,9]

b)

[1,2,4,3,8,9]

c)

[1,4,8]

d)

(1,4,8)

9.

What will be the output of the following Python code?


>>> nums = set([1,1,2,3,3,3,4,4])

>>> print(len(nums))

a)

7

b)

4

c)

Error: Invalid formation of syntax of set

d)

8

10.

Which of the following statements is used to create an empty set?

a)

{ }

b)

set()

c)

[ ]

d)

( )