MCQ Practice Single Best Answer Topic: Python Errors and Exceptions Handling

Q What will be the output after the following statements?
x = ['a', 'b', 1, 2, 'A', 'B']
x.sort()
print(x)

Question ID
#3995
Subchapter
Python Errors and Exceptions Handling
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A TypeError
  • B ['a', 'b', 'c', 'A', 'B', 'C']
  • C ['a', 'A', 'b', 'B', 'c', 'C']
  • D ['A', 'B', 'C', 'a', 'b', 'c']
Correct Answer: A

Explanation

TypeError
 
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [83], in ()
      1 x = ['a', 'b', 1, 2, 'A', 'B']
----> 2 x.sort()
      3 print(x)

TypeError: '<' not supported between instances of 'int' and 'str'

Share This Question

Share this MCQ with your friends or study group.