# 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%2FpMGKMvjtl0NDbthH6sWl%2FPySpark_access%20cell%20(1).mp4?alt=media&token=edf5bee6-de95-4d4b-bb07-5440c67b1e56>" %}

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.

* Navigate to a Notebook.
* A cell to write and execute code opens under the selected Notebook.

<figure><img src="https://859511478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2Fy4eATCaIzHrg4G4qiemB%2Fimage.png?alt=media&#x26;token=ac2048a4-7d54-4566-9864-3b84cf2e5d48" alt=""><figcaption><p>By default a Code gets added to a new Notebook</p></figcaption></figure>

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

<figure><img src="https://859511478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FzeZ8CIszlstlKBKp1was%2Fimage.png?alt=media&#x26;token=69c72be5-6987-429c-a2a1-388d94963ca5" alt=""><figcaption><p>Write the code and run it</p></figcaption></figure>

* 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://859511478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FVQKIqcGqnxzCtIx8nCHI%2Fimage.png?alt=media&#x26;token=7e52506d-c7e5-4456-8c9e-6e9b50e07f2f" alt=""><figcaption><p>While running the first cell one more cell gets added</p></figcaption></figure>

* Once the code is run successfully a checkmark appears below the Run cell icon.
* The number before a cell indicates the count of the input executions for the notebook.

<figure><img src="https://859511478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2F0KD7OWulQT7uboq782f4%2Fimage.png?alt=media&#x26;token=c9e298a9-79fa-423e-8a89-9b86acb58647" alt=""><figcaption><p>When code gets run successfully</p></figcaption></figure>

* Click the Save icon provided for the Notebook.
* The Notebook gets saved with the new update.
* A notification message appears to indicate the completion of the action.

<figure><img src="https://859511478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FCgvuxYaNIcDGxJSJQLcB%2Fimage.png?alt=media&#x26;token=68eb9913-c37e-41b5-ba0b-c6edbfdf855a" alt=""><figcaption><p>Saving the Notebook</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="/files/qxlWHN2GGnCXwiFRiS7O" 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.*
  {% 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-pyspark-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.
