ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
def is_anagram(a, b):
    return sorted(a) == sorted(b)
print(is_anagram('listen', 'silent'), is_anagram('abc', 'abcc'), is_anagram('Aa', 'aa'))
  1. A. True False True
  2. B. False False False
  3. C. True True False
  4. D. True False False

Correct answer: D. True False False

'listen' and 'silent' have the same letters, but the lengths of 'abc' and 'abcc' differ. Sorting is case-sensitive, so 'A' and 'a' are different characters.

More Python Programming questions

Exams that ask this topic