Prerequisites:
Install py2exe v0.6.9 which is compatible with python 2.7
Follow below Steps:
1.Save your code in to test.py (or any name with .py extension) file. Make sure that the code works fine by running it using python.
2.Then create a new file with name setup.py and paste the following code in to it.
from distutils.core import setup
import py2exe
setup(console=['test.py'])
3.Now it is time to run the script and create the executable. To build the executable, run "python setup.py py2exe" on the command prompt.
4.After Building the executable is finished. Now you can find test.exe in the \dist sub folder. Move to dist sub folder and run test.exe, you can see output in console.
Hope it helps you..!!
Thanks