ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
def f(s):
    return s[::-1] == s
print(f('abba'), f('ab' * 2), f(''), f('a'))
  1. A. True True True True
  2. B. True False True True
  3. C. True False False True
  4. D. False False True True

Correct answer: B. True False True True

abba reads the same backwards, and so does the empty string and a single character. 'abab' is not a palindrome.

More Python Programming questions

Exams that ask this topic