ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(sum([1, 2], 0.5))
- A. 3
- B. 3.0
- C. 2.5
- D. 3.5
Correct answer: D. 3.5
The start value 0.5 is a float, so the running total becomes a float, and 0.5 + 1 + 2 is 3.5.
More Python Programming questions
- What is printed? python import heapq def topo(n, edges): indeg = [0] n adj = [[] for in range(n)] for u, v in edges: adj[u].append(v)…
- Which operation is O(1) amortised in CPython and removes the first item, while list.pop(0) is O(n)?
- What is printed? python print(sorted('bca', reverse=True)[0], 'bca'.index('c'))
- What is printed? python from collections import defaultdict d = defaultdict(int) d['x'] += 2 d['y'] print(dict(d))
- What is printed? python print(list(map(pow, [2, 3], [3, 2])))
- What is printed? python print(min(['10', '9', '2']), min([10, 9, 2]))