How can I test if a number is an integer without using type( )?
The instructions want us to not use the built in
type() function to determine if the given number
x is an integer or not. To do this, we’ll need to round the value given to us, and we can do that using one of two functions:
floor(), which are both available through the
math module we learned about earlier.
We can do this because if we round a number and it’s different than our initial number, we know the number given was a float. For example, if we’re given 78.6 and we round it, we’ll have 79. The difference between the two is not 0, so we know we were given a float!