ProgrammingModerateInfosys HackWithInfy · TCS CodeVita

What is printed?

What is printed?
def is_rot(a, b):
    return len(a) == len(b) and b in a + a
print(is_rot('abcde', 'cdeab'), is_rot('abc', 'acb'), is_rot('', ''))
  1. A. True False True
  2. B. True True True
  3. C. False False True
  4. D. True False False

Correct answer: A. True False True

A rotation appears inside the doubled string, and the length check rules out unequal lengths. cdeab appears in abcdeabcde, acb is not a rotation of abc, and two empty strings match.

More Python Programming questions

Exams that ask this topic