Open in CoCalc
s = "a = 5\n%gp ellinit([1,2,3,4,5])\nprint a"
smc.execute("def f(n):\n return n*2\n\nf(10)\nf(20)")
20 40
reset()
x = dict(globals()) smc.execute("a = 5; b = 7; c = a*b; print c", namespace=x)
35
x['c']
35
c
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 982, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> NameError: name 'c' is not defined