#!/usr/bin/env python # coding: utf-8 # ## Jupyter Notebook test2 # In[1]: # Run external python script file, same working directory. # Use magic command, "%run". get_ipython().run_line_magic('run', 'pytest1.py') # In[2]: # Run internal codes copied to a cell in a Jupyter Notebook. """pytest1.py copy.""" # global variables. var1 = 100 var2 = 200 print "var1", var1, "var2", var2 # Should print "var1 100 var2 200" # Starting short test function. def myfunc(a, b): a = a + 10 b = b - 2 print "new var1", a, "new var2", b # Should print "new var1 110 new var2 198" return(a, b) # Call myfunc(a, b), returns changed a, b. print('returned values:', myfunc(var1, var2)) print "global", var1, var2 print "Done" Both methods of running the python script produced the same results.