ProgrammingModerateTCS NQT · Accenture
What is printed?
What is printed?
print('hello world'.translate({ord('l'): None, ord('o'): 'O'}))- A. heOO wOrd
- B. heO wOrd
- C. hel wOrd
- 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
- What is printed? python class N: def init(self, v): self.v = v self.nxt = None def hascycle(h): slow = fast = h steps = 0 while fast and…
- What is printed? python print(hash(-1), hash(-2), hash(-1) == -2, hash(1) == hash(1.0))
- What is printed? python print(232, (23)2, -22, (-2)2, 2-12)
- What is printed? python print(float(254) + 1 == 254, 254 + 1 == float(254), 1e16 + 2 == 1e16 + 1)
- What is printed? python print(int('١٢٣'), int('0' 2 + '5'), int('5' + '0' 2), int(' t7n'))
- What is printed? python print(bin(-8 & 0xFF), (-8) >> 1, (-8) // 2, (-9) // 2, -9 >> 1)