ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(''.join(chr(ord('a') + (ord(c) - ord('a') + 3) % 26) for c in 'xyz'))
  1. A. bcd
  2. B. abc
  3. C. uvw
  4. D. xyz

Correct answer: B. abc

This is a Caesar shift by 3 with wrap-around modulo 26. x, y and z move to a, b and c.

More Python Programming questions

Exams that ask this topic