ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
x = 'AbC'
print(x.swapcase(), x.lower() < x.upper(), sorted(x) == ['A', 'C', 'b'])
  1. A. aBc True True
  2. B. aBc False False
  3. C. aBc True False
  4. D. aBc False True

Correct answer: D. aBc False True

swapcase gives aBc. 'abc' starts with a (97), which is larger than A (65), so the comparison is False. sorted puts A, C and b in code-point order, so that check is True.

More Python Programming questions

Exams that ask this topic