Code Cells

Contents

2.3. Code Cells#

You can write your Python code in code cells in your Notebook.

To create a code cell:

  1. Click on the +Code button colab-code from the top right-hand-side notebook toolbar.

  2. A code cell will be created. You can now start writing your Python code inside the code cell.

  3. As before, to run the code cell, click on Play icon colab-play in the left gutter of the cell to get the output of the code displayed underneath the code cell.

Below is an example of how a code cell and its output after running the code cell will look in your Notebook.

_images/jupyter-code-cell.png

Fig. 2.3 An example of a code cell in Jupyter Notebook and its output.#

Exercise 2.3 (Exploring code cells)

Level:

Explore writing Python code in code cells. Write the code shown in Fig. 2.3, and execute it in a Jupyter Notebook. Name this file as notebook3.ipynb

2.3.1. Sharing#

On Google Drive, if you go to the location where you have saved your notebook, you should be ble to see your Notebook file/s (.ipynb) in that folder. You can send the .ipynb file to someone or share it directly with others via Google Drive using the Share button at the top right-hand-side of the Colab document. You can also get a link from there and use the link to share it with your collaborators.

Exercise 2.4 (Explore how others do Notebooks)

Level:

This link contains different examples of Jupyter Notebooks for you to explore. Look into a few Notebooks and check the .ipynb files to see how others are displaying content in Notebooks.