ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
s = 'x' t = s s = s + 'y' print(t, s, t is s)
- A. xy xy True
- B. x xy False
- C. x xy True
- D. x x False
Correct answer: B. x xy False
Concatenation builds a new string, and s is rebound to it. t still refers to the old 'x' object, so the two names are no longer the same object.
More Python Programming questions
- What is printed? python print(''.join(map(chr, [72, 105])), ord('A') > 127, len('ab'.encode('utf-8')))
- What is printed? python print(list('hi'.encode('utf-16-le')), len('hi'.encode('utf-32')))
- What is printed? python print(bytes([104, 105]).decode(), bytes(b'ab').hex(), bytes([10, 255]).hex())
- What is printed? python print(f'{0.1:.1f}', f'{0.25:.1f}', f'{0.35:.1f}', f'{0.45:.1f}')
- What is printed? python print(5 // 2 2, 5 >> 2, 5 / 2 2)
- What is printed? python print(1 + 2 3 2 // 4 % 5, (1 + 2) 3 2 // 4 % 5)