Jupyter Notebook test2

In [1]:
# Run external python script file, same working directory.
# Use magic command, "%run".
%run pytest1.py
var1 100 var2 200
new var1 110 new var2 198
('returned values:', (110, 198))
global 100 200
Done
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"
var1 100 var2 200
new var1 110 new var2 198
('returned values:', (110, 198))
global 100 200
Done
Both methods of running the python script produced the same results.