ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(sum(map(int, '1234')), '1234'[::-1] == '4321')
- A. 1234 True
- B. 10 False
- C. 11 True
- D. 10 True
Correct answer: D. 10 True
The digits of 1234 add to 10, and reversing the string gives 4321, so the comparison is True.
More Python Programming questions
- What is printed? python import heapq pts = [(1, 3), (-2, 2), (2, -2), (0, 1)] print(heapq.nsmallest(2, pts, key=lambda p: p[0] 2 + p[1] 2))
- What is printed? python d = {} try: d[[1]] = 2 except TypeError as e: print(type(e).name) print(d)
- What is printed? python from functools import reduce print(reduce(lambda a, b: a 10 + b, [1, 2, 3]), reduce(lambda a, b: a - b, [10, 2…
- What is printed? python print(sum(x for x in range(1, 11) if x % 2 == 0) - sum(x for x in range(1, 11) if x % 2))
- What is printed? python print('a,b,,c'.split(','), 'a b'.split())
- What is printed? python t = (1, 2) t += (3,) print(t, len(t))