ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(bool(0.0), bool(-0.0), bool(1e-300), bool(float('nan')))- A. False True True True
- B. True False True True
- C. False False True True
- D. False False True False
Correct answer: C. False False True True
Zero floats, including -0.0, are false. Any other nonzero float is true, and NaN is true because it is not zero.
More Python Programming questions
- What is printed? python print(sum(i i for i in range(1, 4)), sum(i 2 for i in range(1, 4)) == 14)
- What is printed? python print(round(1234.5678, -2), round(-1.5), round(-2.5), round(0.1 + 0.2, 1))
- What is printed? python import heapq rooms = [] for start, end in sorted([(1, 4), (2, 3), (3, 5)]): if rooms and rooms[0] <= start…
- What is printed? python print(' '.join(str(x) for x in range(3, 0, -1)), ' '.join(map(str, [])) == '')
- What is printed? python def gensquares(n): for i in range(n): yield i i print(list(gensquares(4)), sum(gensquares(4)), max(gensquares(0)…
- What is printed? python x = 255 print(f'{x:x}', f'{x:08b}', f'{x:o}', f'{x:#06x}')