NEW
Font size
WorksheetsPodiumRound
Total questions: 25
Worksheet time: 13mins
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) [1, 2, 3, 4, 5]
b) [1, 2, 10, 4, 5]
c) [1, 10, 3, 4, 5]
d) Error: Lists are immutable
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) (1, 2, [3, 4])
(1, 2, [10, 4])
c) Error: Tuples are immutable
d) (1, 10, [3, 4])
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': 1, 'b': {'x': 10, 'y': 20}, 'c': 3}
b) {'a': 1, 'b': {'x': 10, 'y': 20, 'z': 30}, 'c': 3}
c) {'a': 1, 'b': {'z': 30}, 'c': 3}
d) Error: Cannot add new keys to a dictionary
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) [1, 2, 3, 4, 5, 6]
c) [1, 2, 5, 6]
c) {1, 2, 5, 6}
d) Error: symmetric_difference() is not a method of sets
Which of the following set operations will return a set containing elements that are in either set, but not in both?
A) union()
B) intersection()
C) difference()
D) symmetric_difference()
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) 2, 5
B) 3, 5
C) 2, 3
D) 2, 1
Given the following tuple:
t = (1, 2, 3, 4, 5)
Which of the following operations will not raise an error?
A) t[2] = 10
B) t.append(6)
C) t = t + (6,)
D) del t[0]
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) (2, 1), (3, 1), (3, 2)
b) (1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)
c) (2, 1), (2, 3), (3, 1), (3, 2)
d) (1, 2), (2, 3), (3, 1), (3, 2)
How many times will "Hello" be printed?
count = 0
while count < 5:
print("Hello")
if count % 2 == 0:
continue
count += 1
a) 5 times
b) Infinite times
c) 2 times
d) 0 times
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) [0, 0, 2, 2, 4, 4]
b) [0, 0, 2, 2, 2, 4, 4, 4, 4]
c) [0, 2, 4]
d) [0, 2, 4, 6, 8]
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) key1 only
b) key1 and key2
c) All keys are valid
d) Error
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) {1: 'odd', 2: 'even', 3: 'odd', 4: 'even', 5: 'odd', 6: 'even'}
b) {1: 'odd', 2: 'even', 3: 'odd', 4: 'odd', 5: 'odd', 6: 'even'}
c) {1: 'even', 2: 'even', 3: 'odd', 4: 'even', 5: 'even', 6: 'even'}
d) Error
What will the following code output?
numbers = [1, 2, 3, 4, 5, 6]
result = numbers[::-2]
print(result)
a) [6, 4, 2]
b) [5, 3, 1]
c) [6, 4, 2, 0]
d) Error
Which of the following list operations has a time complexity of O(n)?
A. list1.append()
B. list1.remove()
C. list1.insert()
D. list1.extend()
What is the result of the following code snippet?
tuple1 = (1, 2, 3)
tuple2 = tuple1 * 2
tuple2[0] = 10
print(tuple2)
a) (1 ,2 ,3 ,1 ,2, 3)
b) [1 ,2 ,3 ,1 ,2, 3]
c) [1 ,1]
d) Error
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
B. B
C. C
D. It raises a SyntaxError
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. {1, 2}
B. {5, 6}
C. {3, 4}
D. {1, 2, 5, 6}
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. [1, 6, 7, 8, 5]
B. [1, 6, 7, 8, 4, 5]
C. [1, 6, 7, 8]
D. [6, 7, 8]
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. (2, 3, 4, 2, 3, 4, 6, 7)
B. (1, 2, 3, 4, 5, 6, 7)
C. (2, 3, 4, 2, 3, 4, 6, 7, 5)
D. (2, 3, 4, 6, 7)
str1 = '{2}, {1} and {0}'.format('a', 'b', 'c')
str2 = '{0}{1}{0}'.format('abra', 'cad')
print(str1, str2)
a) c, b and a abracad
b) a, b and c abracadabra
c) a, b and c abracadcad
d) c, b and a abracadabra
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)
2.0000 2 -8 3.77
2.000 3 -8 3.77
2.000 2 8 3.77
2 3.77 -8 3.77
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=' ')
[‘What’, ‘will’, ‘have’, ‘so’, ‘will’]
Wh t will h ve so will
What will have so will
[‘Wh’, ‘t will h’, ‘ve so will’]
What is the output of the following program?
my_string = "maksad"
i = "i"
while i in my_string:
print(i, end =" ")
maksad
i i i i i i .....
m a k s a d
No output
What is the output of the following program?
tuple1 = (1, 2, 4, 3)
tuple2 = (1, 2, 3, 4)
print(tuple1 < tuple2)
Error
True
False
Unexpected
What is the output of the following code :
L = ['a','b','c','d']
print("".join(L))
Error
None
abcd
[‘a’,’b’,’c’,’d’]
