How can I execute a function from a separate script?
You can just import the second file from the first and then call it's functions.

Imagine you have two scripts, foo and bar, stored in foo.py and bar.py, respectively; the script bar has a function which you want to call from the script foo. All you need to dois import bar at the start of foo and then call it's function, as in this example:

#File bar.py
def test():
    print("Hello, World!")


#File foo.py
import bar

bar.test() #Outputs "Hello, World!" to the console