Python MCQs with answers Page - 18

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 • 831.35K Points
Coach

Q. Which of the following is a Python tuple?

  • (A) {1, 2, 3}
  • (B) {}
  • (C) [1, 2, 3]
  • (D) (1, 2, 3)

A

Admin • 831.35K Points
Coach

Q. What will be the output of the following Python expression?

Code:
round(4.576)
  • (A) 4
  • (B) 4.5
  • (C) 5
  • (D) 4.6

A

Admin • 831.35K Points
Coach

Q. Which of the following is a feature of Python DocString?

  • (A) In Python all functions should have a docstring
  • (B) Docstrings can be accessed by the __doc__ attribute on objects
  • (C) It provides a convenient way of associating documentation with Python modules, functions, classes, and methods
  • (D) All of the mentioned

A

Admin • 831.35K Points
Coach

Q. What is output of print(math.pow(3, 2))?

  • (A) 9.0
  • (B) None
  • (C) 9
  • (D) None of these

A

Admin • 831.35K Points
Coach

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

  • (A) Every object in Python doesn’t have a unique id
  • (B) In Python Id function returns the identity of the object
  • (C) None of the mentioned
  • (D) All of the mentioned

A

Admin • 831.35K Points
Coach

Q. The process of pickling in Python includes ____________

  • (A) conversion of a datatable into a list
  • (B) conversion of a Python object hierarchy into byte stream
  • (C) conversion of a list into a datatable
  • (D) conversion of a byte stream into Python object hierarchy

A

Admin • 831.35K Points
Coach

Q. What will be the output of the following Python code?

Code:
def foo():
    try:
        return 1
    finally:
        return 2
k = foo()
print(k)
  • (A) 1
  • (B) 2
  • (C) 3
  • (D) error, there is more than one return statement in a single try-finally block

A

Admin • 831.35K Points
Coach

Q. What is the maximum possible length of an identifier?

  • (A) 31 characters
  • (B) 63 characters
  • (C) 79 characters
  • (D) none

A

Admin • 831.35K Points
Coach

Q. Which of the following is invalid?

  • (A) __str__ = 1
  • (B) _a = 1
  • (C) __a = 1
  • (D) None

A

Admin • 831.35K Points
Coach

Q. Which of the following is an invalid variable?

  • (A) foo
  • (B) 1st_string
  • (C) my_string_1
  • (D) _

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