Explore topic-wise MCQs in Technical Programming.

This section includes 1007 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

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
2.

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]
3.

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
4.

What is the output of the following program:

A. dlroW olleH
B. Hello Worl
C. d
D. Error
Answer» B. Hello Worl
5.

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%
6.

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
7.

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].
8.

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.
9.

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]
10.

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
11.

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‟
12.

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.
13.

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‟].
14.

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].
15.

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
16.

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
17.

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

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

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
19.

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.
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?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
22.

What is the output of the following program :

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

What is the output of the expression : 3*1**3

A. 27
B. 9
C. 3
D. 1
Answer» D. 1
24.

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

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

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
26.

Which of these is not a core data type?

A. Lists
B. Dictionary
C. Tuples
D. Class
Answer» E.
27.

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
28.

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

A. print(“-ns”%S)
B. print(“-ns”%S)
C. print(“%ns”%S)
D. print(“%-ns”%S)
Answer» E.
29.

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

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

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

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

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
32.

What will be displayed by the following code?def f(value, values): v = 1 values[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.
33.

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

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

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
35.

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
36.

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]]
37.

What is the output of the following program :i = 0while i < 3: print i print 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
38.

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
39.

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
40.

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}
41.

What is the output of the following program : print 'cd'.partition('cd')

A. („cd‟)
B. (”)
C. („cd‟, ”, ”)
D. (”, „cd‟, ”)
Answer» E.
42.

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

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

_____variable is shared by all instances of a class

A. class
B. instance
C. gloabal
D. local
Answer» B. instance
44.

Through Which Geometry method we can organizes widgets in a table-like structure in the parent widget.

A. position()
B. grid()
C. pack()
D. place()
Answer» C. pack()
45.

Which geometry manager organizes widgets in blocks before placing them in the parent widget.

A. position()
B. grid()
C. pack()
D. place()
Answer» D. place()
46.

How many types of geometry manager classes?

A. three
B. two
C. four
D. one
Answer» B. two
47.

What is the output for the following code:languages = ["java", "c++", "python"]for x in languages :if x == "c++":continueprint(x)

A. java
B. javapython
C. javac++python
D. c++python
Answer» C. javac++python
48.

Which of the following is mathematical function?

A. power
B. sqrt
C. add
D. sub
Answer» C. add
49.

To access value in tuple, use the ________ bracket for slicing along with the index.

A. square
B. round
C. not necessary
D. triangle
Answer» B. round
50.

To read the entire remaining contents of the file as a string from a file object infile, we use ____________

A. infile.readall()
B. infile.read()
C. infile.readlines()
D. infile.read(all)
Answer» C. infile.readlines()