ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(''.join(reversed('ab' * 2)), 'ab'[::-1] * 2 == 'baba')
  1. A. abab True
  2. B. baba False
  3. C. baba True
  4. D. abab False

Correct answer: C. baba True

Reversing 'abab' gives 'baba'. The slice 'ab'[::-1] is 'ba', and repeating it twice gives 'baba'.

More Python Programming questions

Exams that ask this topic