Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Jupyter notebook document examples
Last updated at 1:48 pm UTC on 15 May 2019
The two Jupyter notebooks files (JSON documents) below were made with the standalone electron based application nteract. As Jupyter 'kernel' node.js is used. (thus the scripting engine supports 'JavaScript', https://github.com/n-riesco/ijavascript).

The Jupyter notebook file format could also be used to store Squeak dynabook content (No implementation yet).

https://nbformat.readthedocs.io/en/latest/format_description.html#notebook-file-format

At the highest level, a Jupyter notebook is a dictionary (a JsonObject) with a few keys:


The meta data is optional.
So the minimum is the following
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "cells" : [
      # list of cell dictionaries, see below
  ],
}


A cell is
 {
   "cell_type" : "type",
   "metadata" : {},
   "source" : "single string or [list, of, strings]",
 }



The first example has three text cells (type 'markdown').
{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "## Introduction\n",
        "lorem ipsum"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Data structures\n",
        "Sed ut perspiciatis unde omnis iste natus"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Control structures\n",
        "Neligat minta strebant plomea."
      ]
    }
  ],

  "metadata": {
    "kernel_info": {
      "name": "node_nteract"
    },
    "language_info": {
      "name": "javascript",
      "version": "8.9.3",
      "mimetype": "application/javascript",
      "file_extension": ".js"
    },
    "kernelspec": {
      "name": "node_nteract",
      "language": "javascript",
      "display_name": "Node.js (nteract)"
    },
    "nteract": {
      "version": "0.11.2"
    }
  },

  "nbformat": 4,

  "nbformat_minor": 4
}




Anoter simple Jupyter notebook file example. It has text and code cells.

{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "(This is a markdown cell)\n",
        "## Arithmetic operations "
      ],
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "// This is a code cell\n",
        "3 + 4"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 8,
          "data": {
            "text/plain": [
              "7"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 8,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## String operations"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "\n'hello'.length"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 9,
          "data": {
            "text/plain": [
              "5"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 9,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "node_nteract"
    },
    "language_info": {
      "name": "javascript",
      "version": "8.9.3",
      "mimetype": "application/javascript",
      "file_extension": ".js"
    },
    "kernelspec": {
      "name": "node_nteract",
      "language": "javascript",
      "display_name": "Node.js (nteract)"
    },
    "nteract": {
      "version": "0.11.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}

JupyterNotebook.png