ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(str.maketrans('ab', 'xy', 'c'), 'abcabc'.translate(str.maketrans('ab', 'xy', 'c')))
  1. A. {97: 120, 98: 121, 99: None} xyxy
  2. B. {97: 120, 98: 121, 99: 99} xyxy
  3. C. {97: 120, 98: 121, 99: None} xyc
  4. D. {97: 'x', 98: 'y', 99: None} xyxy

Correct answer: A. {97: 120, 98: 121, 99: None} xyxy

maketrans maps code points: a (97) to x (120), b (98) to y (121), and the third argument's character c (99) to None, which deletes it. So 'abcabc' becomes 'xyxy'.

More Python Programming questions

Exams that ask this topic