ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
import math print(math.prod([]), math.prod([2, 3.0]))
- A. 1 6.0
- B. 0 6.0
- C. 1 6
- D. 1 5.0
Correct answer: A. 1 6.0
The product of an empty iterable is the start value 1. Multiplying 2 by the float 3.0 gives the float 6.0.
More Python Programming questions
- What is printed? python import heapq h = [1, 3] heapq.heapify(h) print(heapq.heapreplace(h, 0), sorted(h), heapq.heappushpop(h, 0)…
- What is printed? python try: print(list(zip([1, 2], [3], strict=True))) except ValueError: print('strict')
- What is printed? python print(round(1234, -2), round(1250, -2), round(1350, -2))
- What is printed? python def lcsub(a, b): best = end = 0 dp = [[0] (len(b) + 1) for in range(len(a) + 1)] for i in range(1, len(a) + 1)…
- A solution must decide whether a number n up to 10^12 is prime within about one second in CPython. Which approach is correct and fast…
- What is printed? python d = {'a': 1, 'b': 2} print(d.popitem(), d)