Skip to content

Instantly share code, notes, and snippets.

@CesarNog
Last active August 29, 2015 14:13
Function written in Python to verify if any number is an integer. An integer is just a number without a decimal part (for instance, -17, 0, and 42 are all integers, but 98.6 is not). For the purpose of this lesson, we'll also say that a number with a decimal part that is all 0s is also an integer, such as 7.0. This means that, for this lesson, y…
def is_int(x):
if(x < 0):
x = abs(x)
if ((x - int(round(x))) > 0):
return False
else:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment