to run a function in VSCode i have to create an object and then print that object to get the output in console, but i can run it directly from a cell in jupyter notebook, i didn't integrate them , i've run them seperately
--------------Jupyter code--------------
def fun(x):
return x 2
fun(12)
Output
14
But if i want to print the same in Jupyter i have to create an Object and then print that object using print function
--------------VSCode code--------------
def fun(x):
return x 2
a = fun(12)
print(a)
Output
14
Because if i try to run the function in the same way i run it in jupyter, it gives me blanks e.g -
C:\Users\prati\PythonVsCode>
do i have to download a plugin for this function to work?? canuse i can't find anything on this.
CodePudding user response:
Jupyter is based on IPython which by default prints the result of the last expression.
This is not standard behavior for the Python interpreter. You have to print manually. You don't need an extra variable though:
print(fun(12))
Note that the above code should work in Jupyter/IPython as well.