If you are a total Python newbie, I would suggest looking at some Python fundamentals, especially in the areas of modules such as os and sys as these are fundamental to python use.
Have you updated your sys.path to include the directory location of the file?
Does the folder it is in have an __init__.py file so that Python can recognise it as an importable location?
You need to be wary or mindful though, of the way python external to max runs and how it runs as a wrapper for other code in Max.
Often, if you write code in the editor (as Python), it does not always evaluate to what you may expect as I found out while trying to update my sys.path with locations to call scripts from.
The best practice I have so far is below.
in the Maxscript editor, type this (make sure language is set to Python):
import os, sys
print"\n".join(str(i) for i in sys.path)
This will print out the locations Max looks in for modules etc. With this information, you can start to add locations:
As mentioned, you will need a __init__.py file in the scripts location. You can easily do this by navigating to the folder and creating an empty text file. Simply rename it to __init__.py and that's the file required for python to allow imports from that location, but we still need to get the folder location onto the sys.path.
In your location to be added, create a file with the actions, methods and classes (if using them). At the top of the file add this:
import os, sys
fileDir = os.path.dirname(__file__)
if fileDir not in sys.path:
sys.path.append(fileDir)
print"\n".join(str(i) for i in sys.path)
print("The system path has been updated\n\n")
#MORE CODE ETC ETC
Now, Using Ctrl + E (if using the Maxscript Editor) will not give you the result you expect due to the way in which the internal python is being wrapped. What you can do, is to have a .ms file also in the same location which has the following:
thisFile = getFilenamePath(getThisScriptFilename())
python.ExecuteFile(thisFile+"nameOfYourFile.py")
The above file can be open in the maxscript editor, so each time you update your .py file, all you have to do is to use Ctrl + E in the .ms file to run the .py file. This also means that if you like to code in an external ide, you can. I wont add to the confusion by talking about sublime packages to run max code from it, thats another topic.
So, to confirm.
1. Check the sys.path
2. Create a __init__.py file in the folder to call scripts from
3. In your .py file include the sys.path.append() code
4. In the same location, create a.ms file with the maxscript code so you can execute your .py file without having to source it from the run menu or other methods.
Whatever works for you though, many ways to achieve a result.
Hope this helps.