ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(bool(0.0), bool(' '), bool(None is None), bool(float('nan')))- A. False True True False
- B. False True True True
- C. False False True True
- D. True True True True
Correct answer: B. False True True True
0.0 is falsy and a non-empty string is truthy. None is None is True, and NaN is a non-zero float, so bool(nan) is True.
More Python Programming questions
- What is printed? python def findmin(a): lo, hi = 0, len(a) - 1 while lo < hi: mid = (lo + hi) // 2 if a[mid] > a[hi]: lo = mid + 1 else…
- What is printed? python g = {'a': [3, 1], 'b': [2]} for v in g.values(): v.sort() print(g, sorted(g.items(), key=lambda kv: len(kv[1])…
- What is printed? python ops = {} for name in ['add', 'mul']: ops[name] = lambda x, y, n=name: x + y if n == 'add' else x y…
- What is printed? python print(list(enumerate('ab', start=1)), list(zip(reversed([1, 2, 3]), 'xyz')))
- What is printed? python print(hash(1) == hash(True), hash(-1) == -2)
- Which statement about dictionary iteration order in Python 3.7 and later is correct?