ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
from math import prod print(prod([]), prod([2, 3, 4]), prod([1.5, 2]))
- A. 1 24 3
- B. 1 9 3.0
- C. 1 24 3.0
- D. 0 24 3.0
Correct answer: C. 1 24 3.0
The product of an empty iterable is the start value 1. 2 * 3 * 4 = 24, and multiplying the float 1.5 by 2 gives 3.0.
More Python Programming questions
- What is printed? python print(list(range(10, 0, -3)), list(range(0, -7, -2)), len(range(5, 5)), range(3)[1:])
- What is printed? python s = 'abc' print(s.center(7, ''), s.zfill(5), '-'.join(['x']), s.ljust(2, '.'))
- What is printed? python print(divmod(-9, 4), -9 // 4, -9 % 4, round(-9 / 4))
- What is printed? python d = {'x': 1} e = d d = dict(d) d['x'] = 2 print(e['x'], d['x'])
- What is printed? python nums = [3, 3, 1] print(nums.index(3), nums.count(3), [i for i, v in enumerate(nums) if v == 3])
- What is printed? python print(int('0b1011', 2), int('0b1011', 0), int('z', 36), int('1011', 2))