ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
x = 10 y = x y += 1 z = [x] z[0] += 5 print(x, y, z)
- A. 10 11 [15]
- B. 11 11 [15]
- C. 10 11 [10]
- D. 10 11 [11]
Correct answer: A. 10 11 [15]
Integers are immutable, so y += 1 rebinds y and leaves x at 10. z holds the value 10 and z[0] += 5 changes the list to [15].
More Python Programming questions
- What is printed? python a = list('abc') print(a.index('b'), ''.join(a[::-1]), a.pop(0), a)
- What is printed? python x = 5 print(f'{x=}', f'{x 2 = }', f'{"a" 2!r}')
- What is printed? python from math import ceil print(ceil(7 / 2), -(-7 // 2), (7 + 2 - 1) // 2)
- What is printed? python s = 'a b c' print(s.split(' '), s.split(), len(s.split(' ')) - len(s.split()))
- What is printed? python x = 0 for i in range(1, 9): x ^= i print(x, 5 ^ 9 ^ 5, (1 << 3) - 1 & 6)
- What is printed? python s = 'mississippi' print(s.count('ss'), s.count('issi'), s.index('s', 3), s.rindex('i', 0, 5))