Python MCQs with answers Page - 26

Here, you will find a collection of MCQ questions on Python. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 832.27K Points
Coach

Q. The output of this Python code would be

Code:
>>> x={1:”X”,2:”Y”,3:”Z”}
>>> del x
  • (A) the del method does not exist for dictionary
  • (B) the del would delete the values present in dictionary
  • (C) the del would delete the entire dictionary
  • (D) the del would delete all the keys in dictionary

A

Admin • 832.27K Points
Coach

Q. The output of this Python code would be

Code:
sum(1,2,3)
sum([2,4,6])
  • (A) 6, 12
  • (B) Error, Error
  • (C) Error, 12
  • (D) 6, Error

A

Admin • 832.27K Points
Coach

Q. The output of this Python code would be

Code:
def find(x, **y):
print(type(y))
find(‘letters’,X=’1′,Y=’2′)
  • (A) Dictionary
  • (B) An exception is thrown
  • (C) String
  • (D) Tuple

A

Admin • 832.27K Points
Coach

Q. Which one of these is NOT true about recursion?

  • (A) We can replace a recursive function by a non-recursive function
  • (B) The memory space taken by the recursive functions is more than that of non-recursive function
  • (C) Running a recursive function is faster as compared to a non-recursive function
  • (D) The process of recursion makes it easier for users to understand a program

A

Admin • 832.27K Points
Coach

Q. The output of this Python code would be

Code:
a = [‘mn’, ‘op’]
print(len(list(map(list, a))))))
  • (A) 4
  • (B) 2
  • (C) Not specified
  • (D) Error

A

Admin • 832.27K Points
Coach

Q. Which of these functions can NOT be defined under the sys module?

  • (A) sys.argv
  • (B) sys.readline
  • (C) sys.path
  • (D) sys.platform

A

Admin • 832.27K Points
Coach

Q. Which function doesn’t accept any argument?

  • (A) re.compile
  • (B) re.findall
  • (C) re.match
  • (D) re.purge

A

Admin • 832.27K Points
Coach

Q. In Python, find which one isn’t an exception handling keyword.

  • (A) accept
  • (B) finally
  • (C) try
  • (D) except

A

Admin • 832.27K Points
Coach

Q. Find out the private data field among the following:

Code:
def __init__(self):
__m = 1
self.__n = 1
self.__o__ = 1
__p__= 1
  • (A) __m
  • (B) __n
  • (C) __o__
  • (D) __p__

A

Admin • 832.27K Points
Coach

Q. The hasattr(obj,name) is used to

  • (A) check if any specific attribute exists
  • (B) set an attribute
  • (C) access the object’s attribute
  • (D) delete an attribute

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ