Consider the following piece of code.
def calculate(x,y,z=3,w=4):
return(x y z w)
calculate(2,3,4) 5
In the above snippet, the function would return the value 13 to the calling function. But the output isn't displayed as return doesn't print any value and the program terminates. This is how it is in majority of the IDE's.
However, when I run the same program on Jupyter Notebook, it gives me the following Output.
How is 13 getting printed? What is Jupyter Notebook doing that other IDE's don't?
CodePudding user response:
A Jupyter notebook implements a Read-eval-print loop (REPL) which means that the output of the last line of a cell in a Jupyter notebook will always be printed.
There is a great article in the Jupyter docs which explains the basics of the concept really well.
CodePudding user response:
The Jupyter notebook acts as a console instead of a script. If you enter an operation in a python console it will output the solution. There are no print functions needed. E.g.:
>>> 2 2
4