> For the complete documentation index, see [llms.txt](https://docs.bdb.ai/data-science-lab-4/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-4/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="success" %}
*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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/qFuLQb940fmElmEPGGrL/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/UnpKGAxqh5YbYxE2iK0T/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/s77pHycAAbVWxC1sE6J9/image.png)
{% 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/qyVmFYnR3s6RNoN12pQf/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/8IkPRMsuBGldgQQBoXCK/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/fRTA1eQkwSerYkBCM232/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/8OY056oC0y0ZLuAeOcjE/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/1VE2w0zfhZ50ZyqjhPpt/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/mN9mauimZ84Ucq1LMaKw/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/vyoJIezJDdvUkL0i3mrx/image.png" alt=""></td><td>Move the cell up</td><td>Moves the cell upwards</td></tr><tr><td>2</td><td><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/SMJW4moToNpEIDinCv2h/image.png" alt=""></td><td>Move the cell down</td><td>Moves the cell downwards</td></tr><tr><td>3</td><td><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/WLGUtmiSqQZUz1wRIkD2/image.png" alt=""></td><td>Delete Cell</td><td>Deletes the code cell.</td></tr><tr><td>4</td><td><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/x41enJlt2lnibApx3ZJd/image.png" 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-4/data-science-lab-quick-start-flow) *page to get an overview of the **Data Science Lab** module in nutshell.*&#x20;
  {% endhint %}
