An integer is just a number without a decimal part (for instance,
42 are all integers, but
98.6 is not).
For the purpose of this lesson, we’ll also say that a number with a decimal part that is all 0s is also an integer, such as
This means that, for this lesson, you can’t just test the input to see if it’s of type
If the difference between a number and that same number rounded is greater than zero, what does that say about that particular number?
Define a function
is_int that takes a number
x as an input.
return True if the number is an integer (as defined above) and
is_int(7.0) # True is_int(7.5) # False is_int(-1) # True