Yes! You can put your code into a function. E.g. a.py:
def runFunc():
print("Hello from a.py!")
and then import that function from a.py to main.py:
from a import runFunc
If it's inside another folder:
from Folder.a import runFunc
and now main.py:
from a import runFunc
runFunc()
The output's gonna be "Hello from a.py!"
Not really sure what you mean by your question but here is my answer based on my assumption!