# Using a Code Cell

{% 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%2Figrg2b2URgwMO5YmejDu%2Fuploads%2F00aXh2wimHIWsUUio8Bu%2FNotebook%20Cells.mp4?alt=media&token=a3cbe9ad-9677-4296-80b8-3d6427fb6fce>" %}
***Using a code cell under a Notebook***
{% endembed %}

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 BDB DSL Notebook.

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

* 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://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FgLop0zUjIhbz4bC79Sej%2Fimage.png?alt=media&#x26;token=4e323fd8-4012-4427-8793-c514652293a8" alt=""><figcaption><p><em><strong>By default a Code gets added to a new Notebook</strong></em></p></figcaption></figure>

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

<figure><img src="https://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FYSempu8HP7uSVQCzhStX%2Fimage.png?alt=media&#x26;token=894a498e-8e3b-430f-861d-eb82981bc12e" alt=""><figcaption><p><em><strong>Use the Code cell to write a code</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 following image displays how the code for an available Dataset gets inserted while selecting the dataset.*

{% 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://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FMSiZdrSap6bJ2XkRr2t8%2Fimage.png?alt=media&#x26;token=9f0c5e05-04f7-4fa9-b41d-d97a342b20e7" alt=""><figcaption><p><em><strong>While running the first cell one more cell gets added</strong></em></p></figcaption></figure>

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

<figure><img src="https://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FirPkLI7Ww0KA9XTGAmLt%2Fimage.png?alt=media&#x26;token=c2d078fc-16aa-4343-86e2-6c7714cda9f7" alt=""><figcaption><p><em><strong>When code gets run successfully</strong></em></p></figcaption></figure>

* Click the ***Save*** icon provided for the Notebook.
* A notification message appears to indicate the completion of the action.

<figure><img src="https://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FH9CusaPbk3WuA0yaNkcd%2Fimage.png?alt=media&#x26;token=252dc5fd-db99-4bd3-86c2-e508681e7488" alt=""><figcaption><p><em><strong>Saving a Notebook</strong></em></p></figcaption></figure>

* The Notebook status gets changed as saved and the new updates get saved in it.

<figure><img src="https://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FLyqCgNRsIi656eVEL07z%2Fimage.png?alt=media&#x26;token=1e968672-f8c3-460f-bd97-e6efc9c675d2" alt=""><figcaption><p><em><strong>For a saved Notebook Status gets changed as Saved</strong></em></p></figcaption></figure>

{% 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;

<img src="https://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FBovk8K7huzBzaNLIvY6B%2Fimage.png?alt=media&#x26;token=47cc462a-a91c-440b-b203-44d724b7edd0" alt="" data-size="original">

* *While the **Code** and **Markdown** options provided under the **Code** section of the Task Bar adds a new cell before the given code/Markdown cell.*
* *Refer the **Data Science Lab Quick Start Flow** page to get an overview of the **Data Science Lab** module in nutshell.* [***Click here***](https://docs.bdb.ai/data-science-lab/data-science-lab-quick-start-flow) *to get redirected to the quick start flow page.*
  {% 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/project/tabs-for-a-data-science-lab-project/tabs-for-tensorflow-and-pytorch-environment/notebook/notebook-page/notebook-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.
