ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(list(enumerate(['x'], 1))[0][0] + 1)
- A. 1
- B. 2
- C. 0
- D. 3
Correct answer: B. 2
enumerate with start=1 gives index 1 for the first item, and adding 1 gives 2.
More Python Programming questions
- What is printed? python print(list('ab') == ['a', 'b'], 'ab' == ['a', 'b'])
- What is printed? python print(len(dict.fromkeys('aab')), list(dict.fromkeys('aab')))
- What is printed? python print([x for x in [1, 2, 3] for in range(x)])
- What is printed? python print(sorted(['b10', 'b9', 'a100', 'c2'], key=lambda s: (s[0], int(s[1:]))))
- What is printed? python print(sorted([-2, 1, 2, -1], key=abs))
- What is printed? python print('%5.1f|%-5d|' % (3.14159, 42))