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.

451.

Read the code shown below carefully and point out the global variables: y, z = 1, 2 def f(): global x x = y+z

A. x
B. y and z
C. x, y and z
D. Neither x, nor y, nor z
Answer» D. Neither x, nor y, nor z
452.

What is the output of the code shown below? x=100 def f1(): global x x=90 def f2(): global x x=80 print(x)

A. 100
B. 90
C. 80
D. Error
Answer» B. 90
453.

The output of code shown below is: x = 5 def f1(): global x x = 4 def f2(a,b): global x return a+b+x f1() total = f2(1,2) print(total)

A. Error
B. 7
C. 8
D. 15
Answer» C. 8
454.

What is the output of the code shown below? def f(x): print("outer") def f1(a): print("inner") print(a,x) f(3) f1(1)

A. outer error
B. nner error
C. outer inner
D. error
Answer» B. nner error
455.

What is the output of the code shown below? def f(p, q, r): global s p = 10 q = 20 r = 30 s = 40 print(p,q,r,s) p,q,r,s = 1,2,3,4 f(5,10,15)

A. 1 2 3 4
B. 5 10 15 4
C. 10 20 30 40
D. 5 10 15 40
Answer» D. 5 10 15 40
456.

What is the output of the code shown below? def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))

A. [3,2,4]
B. [2,3,4]
C. Error
D. [3,4,2]
Answer» E.
457.

What is the output of the code shown? def f(): global a print(a) a = "hello" print(a) a = "world" f() print(a)

A. hello hello world
B. world world hello
C. hello world world
D. world hello world
Answer» C. hello world world
458.

What is the output of the following code? x=12 def f1(a,b=x): print(a,b) x=15 f1(4)

A. Error
B. 12 4
C. 4 12
D. 4 15
Answer» D. 4 15
459.

What is the output of the code shown below? def f1(x): global x x+=1 print(x) f1(15) print("hello")

A. error
B. hello
C. 16
D. 16 hello
Answer» B. hello
460.

What is the output of the code shown? def f1(): global x x+=1 print(x) x=12 print("x")

A. Error
B. 13
C. 13 x
D. x
Answer» E.
461.

What is the output of the code shown below? def san(x): print(x+1) x=-2 x=4 san(12)

A. 13
B. 10
C. 2
D. 5
Answer» B. 10
462.

What is the output of the code shown below? def f1(): x=100 print(x) x=+1 f1()

A. Error
B. 100
C. 101
D. 99
Answer» C. 101
463.

The output of the code shown below is: def f1(): x=15 print(x) x=12 f1()

A. Error
B. 12
C. 15
D. 1512
Answer» D. 1512
464.

What is the output of the following? def foo(i, x=[]): x.append(x.append(i)) return x for i in range(3): y = foo(i) print(y)

A. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
B. [[0], [[0], 1], [[0], [[0], 1], 2]].
C. [0, None, 1, None, 2, None].
D. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
Answer» D. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]].
465.

Where are the arguments received from the command line stored?

A. sys.argv
B. os.argv
C. argv
D. none of the mentioned
Answer» B. os.argv
466.

What is the output of the following code? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))

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

How are required arguments specified in the function heading?

A. identifier followed by an equal to sign and the default value
B. identifier followed by the default value within backticks (“)
C. identifier followed by the default value within square brackets ([])
D. identifier
Answer» E.
468.

How are default arguments specified in the function heading?

A. identifier followed by an equal to sign and the default value
B. identifier followed by the default value within backticks (“)
C. identifier followed by the default value within square brackets ([])
D. identifier
Answer» B. identifier followed by the default value within backticks (“)
469.

What is the value stored in sys.argv[0]?

A. null
B. you cannot access it
C. the program’s name
D. the first argument
Answer» D. the first argument
470.

What is the type of sys.argv?

A. set
B. list
C. tuple
D. string
Answer» C. tuple
471.

Which module in the python standard library parses options received from the command line?

A. getopt
B. os
C. getarg
D. main
Answer» B. os
472.

How are variable length arguments specified in the function heading?

A. one star followed by a valid identifier
B. one underscore followed by a valid identifier
C. two stars followed by a valid identifier
D. two underscores followed by a valid identifier
Answer» B. one underscore followed by a valid identifier
473.

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

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

What is the output of the following code? def foo(i, x=[]): x.append(i) return x for i in range(3): print(foo(i))

A. [0] [1] [2].
B. [0] [0, 1] [0, 1, 2].
C. [1] [2] [3].
D. [1] [1, 2] [1, 2, 3].
Answer» C. [1] [2] [3].
475.

What is the output of the following code? def foo(x): x = ['def', 'abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))

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

What is the output of the following code? def foo(): total += 1 return total total = 0 print(foo())

A. 0
B. 1
C. error
D. none of the mentioned
Answer» D. none of the mentioned
477.

What is the output of the following code? def foo(): return total + 1 total = 0 print(foo())

A. 0
B. 1
C. error
D. none of the mentioned
Answer» C. error
478.

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

How many keyword arguments can be passed to a function in a single function call?

A. zero
B. one
C. zero or more
D. one or more
Answer» D. one or more
480.

How are keyword arguments specified in the function heading?

A. one star followed by a valid identifier
B. one underscore followed by a valid identifier
C. two stars followed by a valid identifier
D. two underscores followed by a valid identifier
Answer» D. two underscores followed by a valid identifier
481.

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

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

What is the length of sys.argv?

A. number of arguments
B. number of arguments + 1
C. number of arguments – 1
D. none of the mentioned
Answer» C. number of arguments – 1
483.

What is the type of each element in sys.argv?

A. set
B. list
C. tuple
D. string
Answer» E.
484.

What is the output of the following piece of code? def find(a, **b): print(type(b)) find('letters',A='1',B='2')

A. String
B. Tuple
C. Dictionary
D. An exception is thrown
Answer» D. An exception is thrown
485.

What is the output of the following code? def display(b, n): while n > 0: print(b,end="") n=n-1 display('z',3)

A. zzz
B. zz
C. An exception is executed
D. Infinite loop
Answer» B. zz
486.

If a function doesn’t have a return statement, which of the following does the function return?

A. int
B. null
C. None
D. An exception is thrown without the return statement
Answer» D. An exception is thrown without the return statement
487.

What is the output of the following code? def change(one, *two): print(type(two)) change(1,2,3,4)

A. Integer
B. Tuple
C. Dictionary
D. An exception is thrown
Answer» C. Dictionary
488.

What is the output of the following code? def change(i = 1, j = 2): i = i + j j = j + 1 print(i, j) change(j = 1, i = 2)

A. An exception is thrown because of conflicting values
B. 1 2
C. 3 3
D. 3 2
Answer» E.
489.

What is the output of the following code? a=10 b=20 def change(): global b a=45 b=56 change() print(a) print(b)

A. 10 56
B. 45 56
C. 10 20
D. Syntax Error
Answer» B. 45 56
490.

What is the output of the following piece of code? def a(b): b = b + [5] c = [1, 2, 3, 4] a(c) print(len(c))

A. 4
B. 5
C. 1
D. An exception is thrown
Answer» C. 1
491.

What is the output of the following code? i=0 def change(i): i=i+1 return i change(1) print(i)

A. 1
B. Nothing is displayed
C. 0
D. An exception is thrown
Answer» D. An exception is thrown
492.

What is a variable defined inside a function referred to as?

A. A global variable
B. A volatile variable
C. A local variable
D. An automatic variable
Answer» D. An automatic variable
493.

What is a variable defined outside a function referred to as?

A. A static variable
B. A global variable
C. A local variable
D. An automatic variable
Answer» C. A local variable
494.

What is the output of this program? L = [lambda x: x ** 2, lambda x: x ** 3, lambda x: x ** 4] for f in L: print(f(3))

A. 27 81 343
B. 6 9 12
C. 9 27 81
D. None of the mentioned
Answer» D. None of the mentioned
495.

What is the output of below program? def writer(): title = 'Sir' name = (lambda x:title + ' ' + x) return name who = writer() who('Arthur')

A. Arthur Sir
B. Sir Arthur
C. Arthur
D. None of the mentioned
Answer» C. Arthur
496.

What is the output of below program? def f(x, y, z): return x + y + z f(2, 30, 400)

A. 432
B. 24000
C. 430
D. No output
Answer» B. 24000
497.

What is the output of below program? lamb = lambda x: x ** 3 print(lamb(5))

A. 15
B. 555
C. 125
D. None of the mentioned
Answer» D. None of the mentioned
498.

What is the output of this program? y = 6 z = lambda x: x * y print z(8)

A. 48
B. 14
C. 64
D. None of the mentioned
Answer» B. 14
499.

Python supports the creation of anonymous functions at runtime, using a construct called __________

A. Lambda
B. pi
C. anonymous
D. None of the mentioned
Answer» B. pi
500.

What is the output of the below program? def sum(*args): '''Function returns the sum of all values''' r = 0 for i in args: r += i return r print sum.__doc__ print sum(1, 2, 3) print sum(1, 2, 3, 4, 5)

A. 6 15
B. 6 100
C. 123 12345
D. None of the mentioned
Answer» B. 6 100