# Using a Code Cell

A user can write and execute code using the Data Science 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 .ipynb file.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FrSE1mefLYXZ5goDkoB5c%2FUsing%20a%20Code%20Cell.mp4?alt=media&token=d59cc0d7-2ce8-45d9-9da9-795c26ddf28f>" %}
***Using a Code Cell***
{% endembed %}

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> The above-given video displays inserting a new code cell using the Add Pre-cell icon for a code cell.*
{% endhint %}

## Running Code inside a Code Cell

* Create a new .ipynb file. &#x20;

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FfD2EFV6VQuZWWz78FYuM%2Fimage.png?alt=media&#x26;token=a3a71c6d-3840-46d2-a39a-44201d7d5085" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure the creation of the new .ipynb file.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FfyhJ4bZaPxJ0q8Lgz3F2%2Fimage.png?alt=media&#x26;token=03cf5d5d-a6ed-4780-8c5d-d449b6fc4beb" alt=""><figcaption></figcaption></figure>

* Open the newly created .ipynb file.
* Insert the first Code cell by using the Add pre-cell icon.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FIEasTKfKudn7LvA7BsU6%2Fimage.png?alt=media&#x26;token=de499afd-04a9-4697-aa0a-2b215be1007d" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FRLLyrsnTQyv6JNtx7fUL%2Fimage.png?alt=media&#x26;token=b38c05cf-fb29-43ea-9808-8b9045303f70" alt=""><figcaption></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 **Data** tab to get an added data set to the code cell.*
{% endhint %}

* The ***Run*** cell button is changed into the ***Interrupt cell*** icon while running the code.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FotZnd3xEU2e5P4rcNzy2%2Fimage.png?alt=media&#x26;token=e9850aeb-4fcb-412f-a873-27ff928b3300" alt=""><figcaption></figcaption></figure>

* Once the code has run successfully a checkmark appears below the ***Run cell*** icon.
* The code result is displayed below it.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FlJJJPO6VPlnTHivVZutk%2Fimage.png?alt=media&#x26;token=2b91ab5b-66ff-47ec-b99b-538c989f494d" alt=""><figcaption></figcaption></figure>

* Another code cell gets added below (as shown in the following image).
* Click the ***Save*** icon provided for the Notebook.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FHc0xOZIeyKIlym9DhJrW%2Fimage.png?alt=media&#x26;token=6585a854-646c-4420-8f2f-6ac5ad1f544d" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2F0FznDTcmV7Q6AxQz1NZP%2Fimage.png?alt=media&#x26;token=fe3af82b-da8f-47a0-924a-1466438b820d" alt=""><figcaption></figcaption></figure>

## Various Options provided to a Code Cell

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

<table><thead><tr><th width="93">Sl. No.</th><th width="92">Icon </th><th width="178">Name</th><th>Action</th></tr></thead><tbody><tr><td>1</td><td><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/N10fR4fmYhin2PTO5AWP/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/z33KQNYQvBTgQKJBgwTz/blobs/nQo117eNYI5Tn39kyYo3/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/z33KQNYQvBTgQKJBgwTz/blobs/7JV4fPGD3A4MHcGY9zUK/image.png" alt="" data-size="original"></td><td>Delete Cell</td><td>Deletes the code cell.</td></tr><tr><td>4</td><td><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/T27QPRP30wCprxEv9fyu/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,*** ***+Markdown, and +Assist** options provided at the bottom of a cell insert a new cell after the given code/ Markdown cell.*    &#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bdb.ai/data-science-lab-5/data-science-notebook/.ipynb-file-cells/using-a-code-cell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
