The Google Colaboratory (“Colab”) is a notebook (like a Jupyter Notebook) where you can run Python code in your Google Drive.

You can write text, write code, run that code, and see the output – all in line in the same notebook.

Benefits of Google Colab

Sharing notebooks is as easy as sharing any Google document. You can also get the app and run the code from your phone.

You can use the powerful and popular Python language in your Google Drive, and the set-up will take less than five minutes.

Because Python runs on a server (and not in your local browser or on your local computer) you can easily use it to interact with an online database and analyze data in situations where you need to keep the code private.

How to Add Colab to Your Google Drive

  1. On your computer, in your Google Drive, click the “+ new” button.
us0e4vwVAXFLV1Zv_07RINIVP3uMish_sPWjumo8Y8LYBjbBqa5fq7Ioxw7KUmbIGGN18mbUcu16EhLpmWreOsqpHqnwyVt6bFvTKTg0B-FdclBXIumNAGSHm8MRQmuYKCMz7Q9_


2.  Click “more”, then click “connect more apps” at the bottom of that new menu.

kWfy4KkQcuTYxHO0CGiUVsf2PTFRrKEYQzQM1BffRAaarwnIlg3a_zgtD71_NqSzqGnvqRqfTPUi793vgPr6dzNJ6WmhHn9oPePJSaK9h1RNqR5KvwHg2UVj9sYIMBTvizjWtJ_V


3.  In the Google Workspace Marketplace, type “colab” into the search box.

dLHP0JPcfH2VIFFc_cuJeZZ7Kz5UVKGpVxAY_pQNJoGfuBw8Jg6KoLJ_UCETRmgbxmIE8A31VA3BN9KTwXD4hD6CAfHtTIKgNT-vUSVYLK8J_-I-G0YUgVklUB5zQjBKiozuloih

4.  Click to add Google Colaboratory.

BShlQ_Hnj829h2ZNUxCJTolVFTYb7EeBoV7TJyqH13pwiS6YZDX95bxVI0RC3Dqp5wl2Mo-B4r8ezHkWFOeRJxFGGuoY9eQYb2ANtEx0nPCxU9aaZQrqEJj_hbePrYTGheWjr0tM


5.  Now you have Colab in your list of available apps.

Xxwg1qNNyJQDcxrLlmOILOIGhfVQS1jQpTqjbOym7MqhCoVSdRVu_5EdVfrzgiRp70F01k0AUKZo0AQlmGrO3IgGJD-Dpx77jFhWfLXTW0m3ZfYXz5AMoK9m9BhSG-VhK9D-uX_I


How to Use Google Colab

Now when you click the “+new” button and click “more” (at the bottom of that first list) you will see “Google Colaboratory” on the next list.

Click that to open a new Colab notebook. Give your notebook a name, like you would with any Google document or spreadsheet. This notebook is in dark mode:

ttxQIV3tGb3kaiMlu-ix-J0939nbXX7Xx_Ke5UMcBnT_mRNVcNfJevAbMWm8nhIYbCM6zNjSMY_d3CwqIi-euqnf8HSAZlLG5oZST84kDnw9JpxKnLNkj-SioTtL_xhYHfiSgS1c

Type a simple command as a test. To run the code in any cell, you can click the run button on the left side of the code cell (looks like a “play” button with a triangle in a circle) or you can click [shift] + [enter]. The output will appear right below the code cell.

DCX2F45Bewre17_E27tFm0liy5l155iNB7vt4ohbFhCS7QUpwc47JHJ0ipkgJU6AcfKDcmLY8u2q8N-JHdBl1BwkTeM5-BQ250YbH-UwEKiLC8D6gjuo96vGcwwSFPJi0fxqbSkS

You can import many popular libraries without having to install them first.

Ya_VZMKr0gAEs-UJq7BZa-gnjQ3_AQSAq1YK-eCNQBMgibEeFuAl9BwYZvSrhOyC518v5bjJD9gIGs7WQoI87S3cy_cbJdzIScUvYP8pxpTHEhbbRwSLZwX5qojvn7MQPEfOu0F6

If you import a library or define a function in one cell, that will still be available in other cells for at least a few minutes. The runtime will disconnect if you go 30 minutes without running a cell or if you have the notebook open for 12 hours.  

Explore Colab

If you were following along and you now have Google Colaboratory installed, you are ready to build your own projects.

If you click on the “< >” symbol on the bottom-left side of the notebook, you will find code snippets that you can use. Google also has many resources for you, some of which are at https://colab.research.google.com/ (just close out of the pop-up window that appears).

At freeCodeCamp, we are building a curriculum to show you how to use Python to solve math problems. You now have the tools at your fingertips. Happy coding!