Explore topic-wise MCQs in Computer Science Engineering (CSE).

This section includes 38 Mcqs, each offering curated multiple-choice questions to sharpen your Computer Science Engineering (CSE) knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of the following program?D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}D['1'] = 2print(D[D[D[str(D[1])]]])

A. 2
B. 3
C. 2
D. KeyError
Answer» C. 2
2.

What is the output of the following program? tday=datetime.date.today() print(tday.month())

A. August
B. Aug
C. 08
D. 8
Answer» E.
3.

Which of the following formatting options can be used in order to add n blank spaces after a given string S ?

A. print( -ns %S)
B. print( -ns %S)
C. print( %ns %S)
D. print( %-ns %S)
Answer» E.
4.

What is the output of the following program?D = dict()for x in enumerate(range(2)):D[x[0]] = x[1]D[x[1]+7] = x[0]print(D)

A. KeyError
B. {0: 1, 7: 0, 1: 1, 8: 0}
C. {0: 0, 7: 0, 1: 1, 8: 1}
D. {1: 1, 7: 2, 0: 1, 8: 1}
Answer» D. {1: 1, 7: 2, 0: 1, 8: 1}
5.

What is the output of the following code : print 9//2

A. 4.5
B. 4.0
C. 4
D. Error
Answer» D. Error
6.

What is the output of the following program?import stringimport stringLine1 = "And Then There Were None"Line2 = "Famous In Love"Line3 = "Famous Were The Kol And Klaus"Line4 = Line1 + Line2 + Line3print(string.find(Line1, 'Were'), string.count((Line4), 'And'))

A. True 1
B. 15 2
C. (15, 2)
D. True 2
Answer» D. True 2
7.

What is the output of the following program :i = 0while i < 3:print iprint i+1

A. 0 2 1 3 2 4
B. 0 1 2 3 4 5
C. 0 1 1 2 2 3
D. 1 0 2 4 3 5
Answer» D. 1 0 2 4 3 5
8.

What is the output of the following?elements = [0, 1, 2]def incr(x):return x+1print(list(map(elements, incr)))

A. [1, 2, 3].
B. [0, 1, 2].
C. error
D. none of the mentioned
Answer» D. none of the mentioned
9.

What is the output of the following?def to_upper(k):return k.upper()x = ['ab', 'cd']print(list(map(to_upper, x)))

A. [ AB , CD ].
B. [ ab , cd ].
C. none of the mentioned
D. error
Answer» B. [ ab , cd ].
10.

What is the output of the following?elements = [0, 1, 2]def incr(x):return x+1print(list(map(incr, elements)))

A. [1, 2, 3].
B. [0, 1, 2].
C. error
D. none of the mentioned
Answer» B. [0, 1, 2].
11.

What is the output of the following code?def foo(fname, val):print(fname(val))foo(max, [1, 2, 3])foo(min, [1, 2, 3])

A. 3 1
B. 1 3
C. error
D. none of the mentioned
Answer» B. 1 3
12.

What is the output of the following code?def foo(k):k[0] = 1q = [0]foo(q)print(q)

A. [0].
B. [1].
C. [1, 0].
D. [0, 1].
Answer» C. [1, 0].
13.

What is the output of the following program? from math import *a = 2.13b = 3.7777c = -3.12print(int(a), floor(b), ceil(c), fabs(c))

A. 2 3 -4 3
B. 2 3 -3 3.12
C. 2 4 -3 3
D. 2 3 -4 3.12
Answer» C. 2 4 -3 3
14.

What is the output of the following program : print 0.1 + 0.2 == 0.3

A. True
B. False
C. Machine dependent
D. Error
Answer» C. Machine dependent
15.

What is the output of the following program?def REVERSE(L):L.reverse()return(L)def YKNJS(L):List = list()List.extend(REVERSE(L))print(List)L = [1, 3.1, 5.31, 7.531]YKNJS(L)

A. [1, 3.1, 5.31, 7.531]
B. [7.531, 5.31, 3.1, 1]
C. IndexError
D. AttributeError: NoneType object has no attribute REVERSE
Answer» C. IndexError
16.

What is the output of the following?x = ['ab', 'cd']print(len(list(map(list, x))))

A. 2
B. 4
C. error
D. none of the mentioned
Answer» B. 4
17.

What data type is the object below? L = [1, 23, hello , 1]

A. List
B. Dictionary
C. Tuple
D. Array
Answer» B. Dictionary
18.

What is the output of the following program?f = Nonefor i in range (5):with open("data.txt", "w") as f:if i > 2:breakprint(f.closed)

A. True
B. False
C. None
D. Error
Answer» B. False
19.

What is the output of the following program?from math import sqrtL1 = [x**2 for x in range(10)].pop()L1 + = 19print(sqrt(L1), end = " ")L1 = [x**2 for x in reversed(range(10))].pop()L1 + = 16print(int(sqrt(L1)))

A. 10.0 4.0
B. 4.3588 4
C. 10 .0 4
D. 10.0 0
Answer» D. 10.0 0
20.

What is the output of the following program?D = dict()for i in range (3):for j in range(2):D[i] = jprint(D)

A. {0: 0, 1: 0, 2: 0}
B. {0: 1, 1: 1, 2: 1}
C. {0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
D. TypeError: Immutable object
Answer» C. {0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
21.

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 ]
Answer» C. What will have so will
22.

What is the output of the following piece of code?#mod1def change(a):b=[x*2 for x in a]print(b)#mod2def change(a):b=[x*x for x in a]print(b)from mod1 import changefrom mod2 import change#mains=[1,2,3]change(s)

A. [2,4,6].
B. [1,4,9].
C. [2,4,6].
D. There is a name clash
Answer» E.
23.

What is the output of the following program : print '{0:.2}'.format(1.0 / 3)

A. 0.333333
B. 0.33
C. 0.333333:-2
D. Error
Answer» C. 0.333333:-2
24.

What is the output of the following program :i = 0while i < 3:print ii += 1else:print 0

A. 0 1 2 3 0
B. 0 1 2 0
C. 0 1 2
D. Error
Answer» C. 0 1 2
25.

What is the output of the following program : print '{0:-2%}'.format(1.0 / 3)

A. 0.33
B. 0.33%
C. 33.33%
D. 33%
Answer» D. 33%
26.

What will be displayed by the following code?def f(value, values):v = 1values[0] = 44t = 3v = [1, 2, 3]f(t, v)print(t, v[0])

A. 1 1
B. 1 44
C. 3 1
D. 3 44
Answer» E.
27.

What is the output of the following program : def myfunc(a): a = a + 2 a = a * 2 return a print myfunc(2)

A. 8
B. 16
C. Indentation Error
D. Runtime Error
Answer» D. Runtime Error
28.

What is the output of the following program?dictionary1 = {'GFG' : 1,'Google' : 2,'GFG' : 3}print(dictionary1['GFG']);

A. Compilation error due to duplicate keys
B. Runtime time error due to duplicate keys
C. 3
D. 1
Answer» D. 1
29.

Predict the output of following python programsdictionary1 = {'Google' : 1,'Facebook' : 2,'Microsoft' : 3}dictionary2 = {'GFG' : 1,'Microsoft' : 2,'Youtube' : 3}dictionary1.update(dictionary2);for key, values in dictionary1.items():print(key, values)

A. Compilation error
B. Runtime error
C. ( Google , 1) ( Facebook , 2) ( Youtube , 3) ( Microsoft , 2) ( GFG , 1)
D. None of these
Answer» D. None of these
30.

What is the output of the following program?temp = dict()temp['key1'] = {'key1' : 44, 'key2' : 566}temp['key2'] = [1, 2, 3, 4]for (key, values) in temp.items():print(values, end = "")

A. Compilation error
B. { key1 : 44, key2 : 566}[1, 2, 3, 4]
C. Runtime error
D. None of the above
Answer» C. Runtime error
31.

What is the output of the following program : i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0)

A. 0 1 2 0
B. 0 1 2
C. Error
D. None of the above
Answer» C. Error
32.

What is the output of the following program?data = [2, 3, 9]temp = [[x for x in[data]] for x in range(3)]print (temp)

A. [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]
B. [[2, 3, 9], [2, 3, 9], [2, 3, 9]]
C. [[[2, 3, 9]], [[2, 3, 9]]]
D. None of these
Answer» B. [[2, 3, 9], [2, 3, 9], [2, 3, 9]]
33.

What is the output of the following program?data = [x for x in range(5)]temp = [x for x in range(7) if x in data and x%2==0]print(temp)

A. [0, 2, 4, 6]
B. [0, 2, 4]
C. [0, 1, 2, 3, 4, 5]
D. Runtime error
Answer» C. [0, 1, 2, 3, 4, 5]
34.

What is the output of the following program : print 'abcefd'.replace('cd', '12')

A. ab1ef2
B. abcefd
C. ab1efd
D. ab12ed2
Answer» C. ab1efd
35.

What is the output of the following program?L1 = [1, 2, 3, 4]L2 = L1L3 = L1.copy()L4 = list(L1)L1[0] = [5]print(L1, L2, L3, L4)

A. [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
B. [[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]
C. [5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]
D. [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
Answer» E.
36.

What is the output of the following program?T = (1, 2, 3, 4, 5, 6, 7, 8)print(T[T.index(5)], end = " ")print(T[T[T[6]-3]-6])

A. 4 0
B. 5 8
C. 5 IndexError
D. 4 1
Answer» C. 5 IndexError
37.

What is the output of the following program?import sysL1 = tuple()print(sys.getsizeof(L1), end = " ")L1 = (1, 2)print(sys.getsizeof(L1), end = " ")L1 = (1, 3, (4, 5))print(sys.getsizeof(L1), end = " ")L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3))print(sys.getsizeof(L1))

A. 0 2 3 10
B. 32 34 35 42
C. 48 64 72 128
D. 48 144 192 480
Answer» D. 48 144 192 480
38.

What is the output of the following program?L = [1, 3, 5, 7, 9]print(L.pop(-3), end = ' ')print(L.remove(L[0]), end = ' ')print(L)

A. 5 None [3, 7, 9]
B. 5 1 [3, 7, 9]
C. 5 1 [3, 7, 9]
D. 5 None [1, 3, 7, 9]
Answer» B. 5 1 [3, 7, 9]