The markdown with embedded code concept is available for a few languages (R and python among them) but it is a pretty foreign concept for most programmers. So why do we use them? Here are a couple reasons
Explaining a concept
This is a great use of the notebook format. You can have beautiful markdown with embedded, runnable code samples. Well formatted text with hands on code demos can be very valuable. In this notebook I use the format to explain the python module system.
Runnable documentation
In this class we will also use the format to call functions from libraries we write. It makes it easy to explain what your function call is doing and provide a runnable example so people can see it in action.
There are other reasons to use them, but they essentially boil down to being able to use text to explain code or using code to give more understanding to some text that was written.
In [ ]:
import sample
sample.f1()
In [ ]:
import sample2 as s
s.f2()
In [ ]:
from sample3 import f3
f3()
In [ ]:
from sample import *
f1()
In [ ]:
import nest.sample4
nest.sample4.f4()
In [ ]:
import nest.sample4 as s
s.f4()