ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('Ab'.swapcase(), 'ab'.capitalize() == 'Ab', 'AB'.lower() == 'ab', 'a b'.title())
  1. A. aB True False A b
  2. B. AB True True A C
  3. C. aB False True A B
  4. D. aB True True A B

Correct answer: D. aB True True A B

swapcase turns Ab into aB, and capitalize gives Ab for ab. lower() of AB is ab, and title() capitalises each word of a b.

More Python Programming questions

Exams that ask this topic