ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
s = "The quick brown fox"
w = s.split()
print(" ".join(w[::-1]), " ".join(x[::-1] for x in w)[:9], max(w, key=len))
  1. A. fox brown quick The ehT kciuq quick
  2. B. fox brown quick The ehT kciuq brown
  3. C. xof nworb kciuq ehT ehT kciuq quick
  4. D. fox brown quick The ehT kciu quick

Correct answer: A. fox brown quick The ehT kciuq quick

Reversing the word list reverses word order; reversing each word reverses its characters, and the first 9 characters are 'ehT kciuq'. max with key=len returns the FIRST longest word, 'quick' (tied with 'brown').

More Python Programming questions

Exams that ask this topic