How is the is_int logic for 7.0?


#1

is_int logic not getting. some one please help me out


#2

try with this.......this works well

def is_int(x):
if x % 1 == 0 or x % 2 == 0:
return True
else:
return False

print is_int(-7.1)

#3

What you need to get is the numbers after the decimal point and compare it to 0, if it equals 0 return True, else return False.

Here's the code:
def is_int(x):
a = x % 1
if a == 0:
return True
else:
return False