ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
from functools import reduce print(reduce(lambda a, b: a * 10 + b, [1, 2, 3]), reduce(lambda a, b: a - b, [10, 2, 3], 0))
- A. 123 5
- B. 6 -15
- C. 123 -15
- D. 124 -15
Correct answer: C. 123 -15
The first reduce builds the number 123 digit by digit. The second starts at 0 and subtracts each element, giving 0 - 10 - 2 - 3 = -15.
More Python Programming questions
- 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))
- What is printed? python print(abs(-0), abs(-2.5), -(-3))
- What is printed? python print(hex(255), oct(8), bin(-5))
- What is printed? python print(chr(0x41), ord('n'))