ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(" ".join(sorted(set("banana"))))
  1. A. a n b
  2. B. a a a b n n
  3. C. a b n
  4. D. b a n

Correct answer: C. a b n

set("banana") is {'b', 'a', 'n'} in some order. sorted returns ['a', 'b', 'n'] and join puts spaces between them.

More Python Programming questions

Exams that ask this topic