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.

501.

What is the output of the below program? def power(x, y=2): r = 1 for i in range(y): r = r * x return r print power(3) print power(3, 3)

A. 212 32
B. 9 27
C. 567 98
D. None of the mentioned
Answer» C. 567 98
502.

What is the output of the below program? def C2F(c): return c * 9/5 + 32 print C2F(100) print C2F(0)

A. 212 32
B. 314 24
C. 567 98
D. None of the mentioned
Answer» B. 314 24
503.

What is the output of below program? def cube(x): return x * x * x x = cube(3) print x

A. 9
B. 3
C. 27
D. 30
Answer» D. 30
504.

Which of the following refers to mathematical function?

A. sqrt
B. rhombus
C. add
D. rhombus
Answer» B. rhombus
505.

Which of the following is the use of id() function in python?

A. Id returns the identity of the object
B. Every object doesn’t have a unique id
C. All of the mentioned
D. None of the mentioned
Answer» B. Every object doesn’t have a unique id
506.

What is called when a function is defined inside a class?

A. Module
B. Class
C. Another function
D. Method
Answer» E.
507.

Where is function defined?

A. Module
B. Class
C. Another function
D. All of the mentioned
Answer» E.
508.

What are the two main types of functions?

A. Custom function
B. Built-in function & User defined function
C. User function
D. System function
Answer» C. User function
509.

Which are the advantages of functions in python?

A. Reducing duplication of code
B. Decomposing complex problems into simpler pieces
C. mproving clarity of the code
D. All of the mentioned
Answer» E.
510.

Which of the following is a features of DocString?

A. Provide a convenient way of associating documentation with Python modules, functions, classes, and methods
B. All functions should have a docstring
C. Docstrings can be accessed by the __doc__ attribute on objects
D. All of the mentioned
Answer» E.
511.

What is the output of below program? def maximum(x, y): if x > y: return x elif x == y: return 'The numbers are equal' else: return y print(maximum(2, 3))

A. 2
B. 3
C. The numbers are equal
D. None of the mentioned
Answer» C. The numbers are equal
512.

What is the output of the below program? def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(3, 7) func(25, c = 24) func(c = 50, a = 100)

A. a is 7 and b is 3 and c is 10 a is 25 and b is 5 and c is 24 a is 5 and b is 100 and c is 50
B. a is 3 and b is 7 and c is 10 a is 5 and b is 25 and c is 24 a is 50 and b is 100 and c is 5
C. a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50
D. None of the mentioned
Answer» D. None of the mentioned
513.

What is the output of below program? def say(message, times = 1): print(message * times) say('Hello') say('World', 5)

A. Hello WorldWorldWorldWorldWorld
B. Hello World 5
C. Hello World,World,World,World,World
D. Hello HelloHelloHelloHelloHello
Answer» B. Hello World 5
514.

What is the output of the below program? x = 50 def func(): global x print('x is', x) x = 2 print('Changed global x to', x) func() print('Value of x is', x)

A. x is 50 Changed global x to 2 Value of x is 50
B. x is 50 Changed global x to 2 Value of x is 2
C. x is 50 Changed global x to 50 Value of x is 50
D. None of the mentioned
Answer» C. x is 50 Changed global x to 50 Value of x is 50
515.

What is the output of the below program ? x = 50 def func(x): print('x is', x) x = 2 print('Changed local x to', x) func(x) print('x is now', x)

A. x is now 50
B. x is now 2
C. x is now 100
D. None of the mentioned
Answer» B. x is now 2
516.

What is the output of the below program? def printMax(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') printMax(3, 4)

A. 3
B. 4
C. 4 is maximum
D. None of the mentioned
Answer» D. None of the mentioned
517.

What is the output of the below program? def sayHello(): print('Hello World!') sayHello() sayHello()

A. Hello World! Hello World!
B. ‘Hello World!’ ‘Hello World!’
C. Hello Hello
D. None of the mentioned
Answer» B. ‘Hello World!’ ‘Hello World!’
518.

Which keyword is use for function?

A. Fun
B. Define
C. Def
D. Function
Answer» D. Function
519.

Which of the following is the use of function in python?

A. Functions are reusable pieces of programs
B. Functions don’t provide better modularity for your application
C. you can’t also create your own functions
D. All of the mentioned
Answer» B. Functions don’t provide better modularity for your application
520.

What is the output of the function shown below? oct(7) oct(‘7’)

A. Error 07
B. 0o7 Error
C. 0o7 Error
D. 07 0o7
Answer» D. 07 0o7
521.

What is the output of the function: len(["hello",2, 4, 6])

A. 4
B. 3
C. Error
D. 6
Answer» B. 3
522.

Which of the following functions does not throw an error?

A. ord()
B. ord(‘ ‘)
C. ord(”)
D. ord(“”)
Answer» C. ord(”)
523.

What is the output of the function shown below? hex(15)

A. f
B. 0xF
C. 0Xf
D. 0xf
Answer» E.
524.

Which of the following functions will not result in an error when no arguments are passed to it?

A. min()
B. divmod()
C. all()
D. float()
Answer» E.
525.

What is the output of the functions shown below? float(‘-infinity’) float(‘inf’)

A. –inf inf
B. –infinity inf
C. Error Error
D. Error Junk value
Answer» B. –infinity inf
526.

What is the output of the functions shown below? ord(65) ord(‘A’)

A. A 65
B. Error 65
C. A Error
D. Error Error
Answer» C. A Error
527.

The output of the function: float(' -12345\n') (Note that the number of blank spaces before the number is 5)

A. -12345.0 (5 blank spaces before the number)
B. -12345.0
C. Error
D. -12345.000000000…. (infinite decimal places)
Answer» C. Error
528.

Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?

A. reverse(l)
B. list(reverse[(l)])
C. reversed(l)
D. list(reversed(l))
Answer» E.
529.

Which of the following functions accepts only integers as arguments?

A. ord()
B. min()
C. chr()
D. any()
Answer» D. any()
530.

Which of the following functions does not necessarily accept only iterables as arguments?

A. enumerate()
B. all()
C. chr()
D. max()
Answer» D. max()
531.

What is the output of the functions shown below? float('1e-003') float('2e+003')

A. 3.00 300
B. 0.001 2000.0
C. 0.001 200
D. Error 2003
Answer» C. 0.001 200
532.

What are the outcomes of the function shown below? x=3 eval('x^2')

A. Error
B. 1
C. 9
D. 6
Answer» C. 9
533.

What is the output of the function shown below? list(enumerate([2, 3]))

A. Error
B. [(1, 2), (2, 3)]
C. [(0, 2), (1, 3)]
D. [(2, 3)]
Answer» D. [(2, 3)]
534.

What is the output of the functions shown below? divmod(10.5,5) divmod(2.4,1.2)

A. (2.00, 0.50) (2.00, 0.00)
B. (2, 0.5) (2, 0)
C. (2.0, 0.5) (2.0, 0.0)
D. (2, 0.5) (2)
Answer» D. (2, 0.5) (2)
535.

The function divmod(a,b), where both ‘a’ and ‘b’ are integers is evaluated as:

A. (a%b, a//b)
B. (a//b, a%b)
C. (a//b, a*b)
D. (a/b, a%b)
Answer» C. (a//b, a*b)
536.

What is the output of the function complex() ?

A. 0j
B. 0+0j
C. 0
D. Error
Answer» B. 0+0j
537.

What is the output of the following function? complex(1+2j)

A. Error
B. 1
C. 2j
D. 1+2j
Answer» E.
538.

What are the outcomes of the following functions? chr(‘97’) chr(97)

A. a Error
B. a’ a
C. Error a
D. Error Error
Answer» D. Error Error
539.

What is the output of the functions shown below? min(max(False,-3,-4), 2,7)

A. 2
B. False
C. -3
D. -4
Answer» C. -3
540.

What is the output of the function: all(3,0,4.2)

A. True
B. False
C. Error
D. 0
Answer» D. 0
541.

What are the outcomes of the functions shown below? sum(2,4,6) sum([1,2,3])

A. Error, 6
B. 12, Error
C. 12, 6
D. Error, Error
Answer» B. 12, Error
542.

What is the output of the function shown below? import math abs(math.sqrt(25))

A. Error
B. -5
C. 5
D. 5.0
Answer» E.
543.

What is the output of the following function? any([2>8, 4>2, 1>2])

A. Error
B. True
C. False
D. 4>2
Answer» C. False
544.

What is the output of the expression? round(4.5676,2)?

A. 4.5
B. 4.6
C. 4.57
D. 4.56
Answer» D. 4.56
545.

What is the output of the function shown below? all([2,4,0,6])

A. Error
B. True
C. False
D. 0
Answer» D. 0
546.

The function pow(x,y,z) is evaluated as:

A. (x**y)**z
B. (x**y) / z
C. (x**y) % z
D. (x**y)*z
Answer» D. (x**y)*z
547.

What is the output of the expression: round(4.576)

A. 4.5
B. 5
C. 4
D. 4.6
Answer» C. 4
548.

Which of the following functions is a built-in function in python?

A. seed()
B. sqrt()
C. factorial()
D. print()
Answer» E.
549.

What is the output of the following piece of code when executed in Python shell? >>> import collections >>> a=collections.OrderedDict((str(x),x) for x in range(3)) >>> a

A. {‘2’:2, ‘0’:0, ‘1’:1}
B. OrderedDict([(‘0’, 0), (‘1’, 1), (‘2’, 2)])
C. An exception is thrown
D. ‘ ‘
Answer» C. An exception is thrown
550.

What is the output of the following piece of code when executed in Python shell? >>> import collections >>> b=dict() >>> b=collections.defaultdict(lambda: 7) >>> b[4]

A. 4
B. 0
C. An exception is thrown
D. 7
Answer» E.