If you type:
You will see if the number is an integer. 1.0 will return as True. That's because this number is a whole number represented as a float. You could call your
is_int() function like this:
This would return as True. You could add any number you'd like there and you should get the correct result.
To be more explicit, say you wanted to go a little further and have the user input a number to figure out if the number was whole or not. Your code would look something like this:
if x == int(x):
x = float(input("Please enter a number: "))
You would add the float function to the input (on newer versions of Python, at least as far as I can tell) because you want the user to be able to write in floating point numbers and check to see if they are whole numbers, which is part of what the int() function does.
1 is the same as
1.0 is a whole number and that's how
int() will consider it to be when that argument is passed to it.
I hope this makes sense