Session Ready
Exercise

Build notebooks

The first function we will define for our new Python package is called nbuild().

nbuild() will

  • Create a new notebook with the new_notebook() function from the v4 module of nbformat
  • Read the file contents from a list of source files with the read_file() function that we have used in previous exercises
  • Pass the file contents to the new_code_cell() or new_markdown_cell() functions from the v4 module of nbformat
  • Assign a list of the resulting cells to the 'cells' key in the new notebook
  • Return the notebook instance

We've already imported nbformat and all of the above functions.

With nbuild(), we will be able to create Jupyter notebooks from small, modular files!

Instructions
100 XP
  • Create new code cells from the contents of files that end in .py.
  • Create new markdown cells from the contents of all other files.