ProgrammingModerateTCS NQT · Accenture

What is printed?

What is printed?
print('hello world'.translate({ord('l'): None, ord('o'): 'O'}))
  1. A. heOO wOrd
  2. B. heO wOrd
  3. C. hel wOrd
  4. D. heO wO

Correct answer: B. heO wOrd

A translate table maps code points to replacements, and None deletes the character. Both l characters are deleted here and every o becomes O.

More Python Programming questions

Exams that ask this topic