Embercode
✕
Variables and Data TypesQuick quiz

Floats and division by zero

8 questions. Covers Division by zero in Python.

Questions 1 to 5 of 8

  1. 1. What does this program print? ``python total = 0.0 for i in range(10): total += 0.1 print(total) print(total == 1.0) ``
  2. 2. What does this program print? ``python a = float('nan') b = float('inf') print(a, b, b - b) ``
  3. 3. What does this program print? ``python print(int(4.35 * 100), round(4.35 * 100)) ``
  4. 4. True or false, and why? print(0.5 + 0.25 == 0.75) prints True.
  5. 5. True or false: in Python, print(5 / 0.0) prints inf, because a float division by zero gives infinity.

5 question(s) left on this page.