ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
import math print(math.prod([2, 3, 4]), math.prod([]), math.prod([1.5, 2]), math.prod(range(1, 6)) == math.factorial(5))
- A. 24 0 3.0 True
- B. 24 1 3 True
- C. 24 1 3.0 True
- D. 24 1 3.0 False
Correct answer: C. 24 1 3.0 True
math.prod of an empty iterable is the start value 1, and it returns a float when any input is a float. The product of 1 to 5 equals 5!.
More Python Programming questions
- What is printed? python words = ['bb', 'a', 'ccc'] print(max(words), max(words, key=len), min(words, key=len), sorted(words, key=lambda w…
- What is printed? python print(len(f'{1234.5:.0f}'), f'{1234.5:.0f}', f'{1235.5:.0f}', f'{-1234.5:.0f}')
- What is printed? python print(1e3 == 103, int(1e3) is not None, 1e3 // 1 == 103, type(1e3 // 1).name)
- What is printed? python print('%x' % -255, '%o' % 8, '%e' % 0.0, '%.0e' % 12345)
- What is printed? python print(5 & 6 | 1, 5 & (6 | 1), 5 ^ 6 & 1, 1 | 2 ^ 3 & 4)
- What is printed? python print(-1 >> 1, -1 << 2, -5 >> 10, 5 >> -0 if False else 0)