```
def is_int_sol(x):
absoluteCount = abs(x)
typeCount = type(x)
roundCount = round(absoluteCount)
if typeCount and absoluteCount - roundCount == 0:
return True
else:
return False
```

If the objective was simplicity, it is lost on me; and, probably many learners, too.

A quick solution can be got using `floor()`

.

```
from math import floor
def is_int(x):
return x - floor(x) == 0
```

We don’t need to worry about the signs. The floor of a negative number is still negative.

The converse is,

```
def is_float(x):
return x - floor(x) > 0
```

`floor`

always moves leftward on the number line. `ceil`

always moves to the right. `round`

moves both directions but we still do not need `absolute()`

.

```
return x - round(x) == 0 # is integer
return x - round(x) != 0 # is float
```

Using `ceil`

is pretty much the same…

```
from math import ceil
def is_int(x):
return ceil(x) - x == 0
```

The thing about this lesson I believe the author wanted was for learners to do a little research to find as many different ways to accomplish this task as one could.

Take for instance exception handling. This one leverages the fact that floats cannot be interpreted as integer.

```
def is_int(x):
try:
return bin(x) and True
except TypeError:
return False
```

It smacks of using `int()`

or `type()`

but this will work…

```
return isinstance(x, int)
```

Cheap and dirty, anyway. My favorite is,

```
return not x % 1
```

No functions at work, at all. Just the logical `not`

and the modulo operator. When the reader sees the `not`

they know immediately that the return value is `bool`

.

In my own view, this is not the naive solution and very rarely ever surfaces. I lean towards doubt when anyone posts this as their solution.

The simple truth (as I see it) is that a great many learners simply breeze through the lessons and not much sticks. When they get to the Practice Makes Perfect module it shows.