wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PodiumRound

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What will be the output of the following code snippet?

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

my_list[2] = 10

print(my_list)

a)

a) [1, 2, 3, 4, 5]

b)

b) [1, 2, 10, 4, 5]

c)

c) [1, 10, 3, 4, 5]

d)

d) Error: Lists are immutable

2.

What will be the output of the following code snippet?

my_tuple = (1, 2, [3, 4])

my_tuple[2][0] = 10

print(my_tuple)

a)

a) (1, 2, [3, 4])

b)

(1, 2, [10, 4])

c)

c) Error: Tuples are immutable

d)

d) (1, 10, [3, 4])

3.

What will be the output of the following code snippet?

my_dict = {'a': 1, 'b': {'x': 10, 'y': 20}, 'c': 3}

my_dict['b']['z'] = 30

print(my_dict)

a)

a) {'a': 1, 'b': {'x': 10, 'y': 20}, 'c': 3}

b)

b) {'a': 1, 'b': {'x': 10, 'y': 20, 'z': 30}, 'c': 3}

c)

c) {'a': 1, 'b': {'z': 30}, 'c': 3}

d)

d) Error: Cannot add new keys to a dictionary

4.

What will be the output of the following code snippet?

set_a = {1, 2, 3, 4}

set_b = {3, 4, 5, 6}

result = set_a.symmetric_difference(set_b)

print(sorted(result))

a)

a) [1, 2, 3, 4, 5, 6]

b)

c) [1, 2, 5, 6]

c)

c) {1, 2, 5, 6}

d)

d) Error: symmetric_difference() is not a method of sets

5.

Which of the following set operations will return a set containing elements that are in either set, but not in both?

a)

A) union()

b)

B) intersection()

c)

C) difference()

d)

D) symmetric_difference()

6.

Given the following list:

data = [[1, 5, 3], [10, 7, 2], [6, 9, 4]]

number1= data[1][2] )

number2= data[0][1]

print(number1, number2)

a)

A) 2, 5

b)

B) 3, 5

c)

C) 2, 3

d)

D) 2, 1

7.

Given the following tuple:

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

Which of the following operations will not raise an error?

a)

A) t[2] = 10

b)

B) t.append(6)

c)

C) t = t + (6,)

d)

D) del t[0]

8.

What will the following code print?

for i in range(1, 4):

for j in range(1, 4):

if i == j:

break

print(i, j)

a)

a) (2, 1), (3, 1), (3, 2)

b)

b) (1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)

c)

c) (2, 1), (2, 3), (3, 1), (3, 2)

d)

d) (1, 2), (2, 3), (3, 1), (3, 2)

9.

How many times will "Hello" be printed?

count = 0

while count < 5:

print("Hello")

if count % 2 == 0:

continue

count += 1

a)

a) 5 times

b)

b) Infinite times

c)

c) 2 times

d)

d) 0 times

10.

What does the following list comprehension produce?

result = [x for x in range(5) if x % 2 == 0 for y in range(x)]

print(result)

a)

a) [0, 0, 2, 2, 4, 4]

b)

b) [0, 0, 2, 2, 2, 4, 4, 4, 4]

c)

c) [0, 2, 4]

d)

d) [0, 2, 4, 6, 8]

11.

Which of the following can be used as dictionary keys?

key1 = (1, 2, 3)

key2 = [1, 2, 3]

key3 = {1, 2, 3}

d = {key1: "Tuple", key2: "List", key3: "Set"}

a)

a) key1 only

b)

b) key1 and key2

c)

c) All keys are valid

d)

d) Error

12.

What will the following code produce?

numbers = [1, 2, 3, 4, 5, 6]

result = {x: ('even' if x % 2 == 0 else 'odd') for x in numbers}

print(result)

a)

a) {1: 'odd', 2: 'even', 3: 'odd', 4: 'even', 5: 'odd', 6: 'even'}

b)

b) {1: 'odd', 2: 'even', 3: 'odd', 4: 'odd', 5: 'odd', 6: 'even'}

c)

c) {1: 'even', 2: 'even', 3: 'odd', 4: 'even', 5: 'even', 6: 'even'}

d)

d) Error

13.

What will the following code output?

numbers = [1, 2, 3, 4, 5, 6]

result = numbers[::-2]

print(result)

a)

a) [6, 4, 2]

b)

b) [5, 3, 1]

c)

c) [6, 4, 2, 0]

d)

d) Error

14.

Which of the following list operations has a time complexity of O(n)?

a)

A. list1.append()

b)

B. list1.remove()

c)

C. list1.insert()

d)

D. list1.extend()

15.

What is the result of the following code snippet?

tuple1 = (1, 2, 3)

tuple2 = tuple1 * 2

tuple2[0] = 10

print(tuple2)

a)

a) (1 ,2 ,3 ,1 ,2, 3)

b)

b) [1 ,2 ,3 ,1 ,2, 3]

c)

c) [1 ,1]

d)

d) Error

16.

What will be the output of the following code?

x = 7

y = 10

if x > y and x != 5:

print("A")

elif y > x or x == 7:

print("B")

else:

print("C")

a)

A. A

b)

B. B

c)

C. C

d)

D. It raises a SyntaxError

17.

What is the output of the following code snippet?

set1 = {1, 2, 3, 4}

set2 = {3, 4, 5, 6}

result = set1.difference(set2)

print(result)

a)

A. {1, 2}

b)

B. {5, 6}

c)

C. {3, 4}

d)

D. {1, 2, 5, 6}

18.

What will be the output of the following code?

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

list2 = [6, 7, 8]

list1[1:4] = list2

print(list1)

a)

A. [1, 6, 7, 8, 5]

b)

B. [1, 6, 7, 8, 4, 5]

c)

C. [1, 6, 7, 8]

d)

D. [6, 7, 8]

19.

What will be the result of the following code ?

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

tuple2 = tuple1[1:4] * 2

result = tuple2 + (6, 7)

print(result)

a)

A. (2, 3, 4, 2, 3, 4, 6, 7)

b)

B. (1, 2, 3, 4, 5, 6, 7)

c)

C. (2, 3, 4, 2, 3, 4, 6, 7, 5)

d)

D. (2, 3, 4, 6, 7)

20.

str1 = '{2}, {1} and {0}'.format('a', 'b', 'c')

str2 = '{0}{1}{0}'.format('abra', 'cad')

print(str1, str2)

a)

a) c, b and a abracad

b)

b) a, b and c abracadabra

c)

c) a, b and c abracadcad

d)

d) c, b and a abracadabra

21.

What is the output of the following program?

a = 2

b = '3.77'

c = -8

str1 = '{0:.4f} {0:3d} {2} {1}'.format(a, b, c)

print(str1)

a)

2.0000 2 -8 3.77

b)

2.000 3 -8 3.77

c)


2.000 2 8 3.77

d)


2 3.77 -8 3.77

22.

What is the output of the following program?

line = "What will have so will"

L = line.split('a')

for i in L:

print(i, end=' ')

a)

[‘What’, ‘will’, ‘have’, ‘so’, ‘will’]

b)

Wh t will h ve so will

c)

What will have so will

d)


[‘Wh’, ‘t will h’, ‘ve so will’]

23.

What is the output of the following program?
my_string = "maksad"

i = "i"

while i in my_string:

print(i, end =" ")

a)

maksad

b)

i i i i i i .....

c)

m a k s a d

d)

No output

24.

What is the output of the following program?
tuple1 = (1, 2, 4, 3)

tuple2 = (1, 2, 3, 4)

print(tuple1 < tuple2)

a)

Error

b)

True

c)


False

d)


Unexpected

25.

What is the output of the following code :
L = ['a','b','c','d']

print("".join(L))

a)


Error

b)


None

c)

abcd

d)

[‘a’,’b’,’c’,’d’]