It seems that I totally didn’t get what they were asking for in this part…

The way I interpret what they are askin us is - Is the number we call x with an int or a float, IF it is int then that is True and ELSE(float) then that is False…

This is my code(and it actually worked), but the solution is waaaaay different:

def is_int(x):

if x == int(x):

return True

else:

return False

And the Codecademy solution:

def is_int(x):

absolute = abs(x)

rounded = round(absolute)

return absolute - rounded == 0

Can somebody explain what they are actually asking for and explain their solution to me?

And let me take it a step further and call x with the number 7.5, the code will look like this. But can you explain what I am looking at here…?

def is_int(x): #7.5

absolute = abs(x) #7.5

rounded = round(absolute) #8.0

return absolute - rounded == 0 #7.5 – 8.0 which is equal to -0,5 so -0.5 == 0

I see that -0.5 is a float and is not the same as 0 and that will be interpreted as False I guess, but still…whats the deal whit that code…? They want us to find out if the number is an int or a float NOT based on the number it self, but on the differnce between the number and the number when its rounded…? Im I on the right track?

If so I would never in a million years have guessed that thats how Im supposed to write the code…