Skip to main content

3.9) Exercise 2 - float to integer


Design and perform a few tests in IDLE to answer the following question:

What happens when you turn a float into an integer?

  1. It rounds the number to the closest integer
  2. It always rounds up to the higher integer
  3. It truncates the number. In other words, it always rounds down to the lower integer

[tippy title="Hint"]

Hint: try turning a few different floats into integers to be sure of the result.

[/tippy]
[tippy title="Answer"]
Answer: 3
[/tippy]