ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print('Python'[::2], 'Python'[1::2], 'Python'[-2::-2])
  1. A. Pto yhn Ptoh
  2. B. Pto ynh otP
  3. C. Pto yhn otP
  4. D. Pty yhn otP

Correct answer: C. Pto yhn otP

[::2] takes every second character starting at P, and [1::2] starts at y. [-2::-2] walks backward from o, giving o, t and P.

More Python Programming questions

Exams that ask this topic