ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
a = list('abc')
print(a.index('b'), ''.join(a[::-1]), a.pop(0), a)- A. 1 cba a ['a', 'b', 'c']
- B. 1 cba a ['b', 'c']
- C. 1 cba b ['a', 'c']
- D. 1 abc a ['b', 'c']
Correct answer: B. 1 cba a ['b', 'c']
The reversed join is 'cba'. pop(0) removes and returns the first letter, a, leaving ['b', 'c'] for the list shown last.
More Python Programming questions
- 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))
- What is printed? python import math print(math.isqrt(10 12), math.isqrt(2 10 12) 2 <= 2 10 12)