> For the complete documentation index, see [llms.txt](https://docs.bdb.ai/data-science-lab/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/project/tabs-for-a-data-science-lab-project/tabs-for-pyspark-environment/notebook/notebook-page/notebook-cells/using-a-code-cell.md).

# Using a Code Cell

Write & Run Code in a 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%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="https://1025450693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Figrg2b2URgwMO5YmejDu%2Fuploads%2FBovk8K7huzBzaNLIvY6B%2Fimage.png?alt=media&amp;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.*
  {% endhint %}

​​​
