> For the complete documentation index, see [llms.txt](https://docs.bdb.ai/data-science-lab-3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bdb.ai/data-science-lab-3/project/tabs-for-a-data-science-lab-project/tabs-for-tensorflow-and-pytorch-environment/notebook/notebook-page/notebook-cells/using-a-code-cell.md).

# Using a Code Cell

Write & Run Code in a Notebook.

You can write and execute code using the Notebook interface. This section covers the steps to write and run a sample code in the Code cell of the Data Science Notebook.

{% hint style="info" %}
*Check out the given walk-through on how to use a Code Cell under a Notebook.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FjBwizG8YI0qWj2KVyGPx%2FUsing%20a%20code%20cell%20V2.mp4?alt=media&token=51bc9368-f61e-472a-ac76-35513c8da01b>" %}
***Running a Code cell with a code***
{% endembed %}

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> A Code cell gets added by default while creating a new Notebook.*&#x20;
{% endhint %}

## Running Code inside a Code Cell

* Create a new Notebook and open it.
* A cell to write and execute code opens under the selected Notebook by default.

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FsFn1T4lF0CYIeCkfWNJ2%2Fimage.png?alt=media&amp;token=df0b2b37-bdd6-4172-97cd-013f69ccd82a" alt=""><figcaption><p><em><strong>Accessing a Code cell within the Notebook interface</strong></em></p></figcaption></figure>

* Write code inside the cell.
* Click the ***Run cell*** icon to run the code.

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FJ4INb4WzOIqmapyfb1BA%2Fimage.png?alt=media&amp;token=78a066c9-a35c-4b7d-8802-f5ed65dc547a" alt=""><figcaption><p><em><strong>Using Run cell icon after inserting relevant code in the Code cell</strong></em></p></figcaption></figure>

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> The Code cells also get code from the selected Notebook operations by using the right-side panel and selecting a specific option. E.g., The user can use the Datasets tab to get an added data set to the code cell.*

![](https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FLhYpLjABT3sG1YI7u5mO%2Fimage.png?alt=media\&token=3558768e-d68f-4dcb-ab8a-d401a1ee992a)
{% endhint %}

* The Run cell button gets changed into the ***Interrupt cell*** icon while running the code.
* Another code cell gets added below (as shown in the following image).

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FGCUucw2v58R6y8fCGbVa%2Fimage.png?alt=media&amp;token=8e3df260-7310-40e6-ae95-899ba6bf8578" alt=""><figcaption><p><em><strong>A</strong></em> <em><strong>Code Cell while Running action is going on</strong></em></p></figcaption></figure>

* Once the code has run successfully a checkmark appears below the ***Run cell*** icon.

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FcpHF6N0TeRVP5m757okm%2Fimage.png?alt=media&amp;token=e727f468-8d50-4dcd-8094-ad3c05da54ea" alt=""><figcaption><p><em><strong>Checkmark after the Code cell completes the Run cell action</strong></em></p></figcaption></figure>

* The code result gets displayed below it.

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FyKQVAg3NAtA6E41ysHtW%2Fimage.png?alt=media&amp;token=e941defa-728d-4010-90f3-6284bc017ab7" alt=""><figcaption><p><em><strong>Displaying the result based on the inserted code</strong></em></p></figcaption></figure>

* Click the ***Save*** icon provided for the Notebook.

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FJr7HcuN1BHOQXKfQsAQA%2Fimage.png?alt=media&amp;token=bc8fc238-335b-475d-9637-74e7a855b407" alt=""><figcaption><p><em><strong>Saving the Notebook updates</strong></em></p></figcaption></figure>

* A notification message appears to indicate the completion of the action.
* The Notebook status gets changed as saved and the new updates get saved in it.

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FMpGvzerCglGRFVTIJQlw%2Fimage.png?alt=media&amp;token=574e4db1-3eb8-42c8-9cc7-24cf322da5f4" alt=""><figcaption><p><em><strong>Notification message while saving the Notebook cell update</strong></em></p></figcaption></figure>

## ​Various Options provided to a Code Cell

By clicking on an inserted Code cell, some code related options get displayed as shown in the below-given image:

<figure><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2Fozlpno7s9bNS9U2TFuD2%2Fimage.png?alt=media&amp;token=6dc5045b-79f8-4ac4-b7cc-bb0a42dc4fce" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="85">Sl. No.</th><th width="98">Icon </th><th width="203">Name</th><th>Action</th></tr></thead><tbody><tr><td>1</td><td><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FlBv84EofqwEbk49ipwI2%2Fimage.png?alt=media&amp;token=e9ef891c-75e0-4ba0-8b07-f4a993784e06" alt=""></td><td>Move the cell up</td><td>Moves the cell upwards</td></tr><tr><td>2</td><td><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FaCH4TwC7sHpHN93Ui3kx%2Fimage.png?alt=media&amp;token=e87428bd-7caa-4b98-be68-64022f81a92c" alt=""></td><td>Move the cell down</td><td>Moves the cell downwards</td></tr><tr><td>3</td><td><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2Fl4NkoNoUwx5nHpbiohu0%2Fimage.png?alt=media&amp;token=f91f25c5-4816-4636-a48f-670ae58c2074" alt=""></td><td>Delete Cell</td><td>Deletes the code cell.</td></tr><tr><td>4</td><td><img src="https://2587201349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FFD2MLvEX0y02raCLgET9%2Fimage.png?alt=media&amp;token=fef6776c-7cdb-4da4-81c8-158ebb058004" alt=""></td><td>More Actions</td><td><p>Opens four more actions that include: </p><p>Transform, Save Model, Predict, and Save artifact.</p></td></tr></tbody></table>

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark>*

* *The **+Code** and **+Markdown** options provided at the bottom of a cell inserts a new cell after the given code/ Markdown cell.*    &#x20;
* *Refer the* [***Data Science Lab Quick Start Flow*** ](https://docs.bdb.ai/data-science-lab-3/data-science-lab-quick-start-flow)*page to get an overview of the **Data Science Lab** module in nutshell.*&#x20;
  {% endhint %}
