Using Python to determine if a number is whole or decimal


In this example you will learn how to create a Python application that will determine if a given number is whole or decimal.

Step One: Download Python

Python is a cool language. Like Ruby it’s very simple to use. You can download it from the python site. Choose your version, download, install and move onto step two.

Step Two: Simple Python Function

Python functions are defined using the def keyword. In this example we define an isWhole function to check weather the number entered by the user is whole or not.


def isWhole(x):
	if(x%1 == 0):
		return True
		return False

You’ll notice that after the function definition there is a colon and there are no semi colons at the end of lines. This is because indention is used to perform code blocks. Using indented code blocks, it is thought, will make the code easier to read.

Read More