What is Google Colab Notebook?

Google Colaboratory, or “Colab” for short, is a cloud-based Jupyter Notebook environment that makes it easy to write and execute Python code.

A Google Colab Notebook is a free Jupyter Notebook that allows you to share, collaborate on, and edit code with other users. It is similar to the popular Jupyter Notebook but offers many more features, including the ability to run code on GPUs and TPUs.

Google Colab notebooks are stored in your Google Drive and can be accessed from any computer with an internet connection.

Getting Started with Google Colaboratory

Now that we’ve answered the question “what is Google Colaboratory?”, let’s take a look at how you can get started using it. First, head over to https://colab.research.google.com/ and sign in with your Google account. Once you’re signed in, you’ll be taken to the Colab home page, which looks something like this:

welcom colab

From the Colab home page, you can either create a new notebook or open an existing one. To create a new notebook, click the “New Notebook” button in the top-right corner of the screen. You’ll be prompted to enter a name for your notebook; once you’ve done so, click the “Create Notebook” button. (Or choose File -> Notebook)

new notebook

You should now see a blank notebook and enter some code to run that looks something like this:

Hello World notebook

As you see, you can write and execute code directly in your browser without having to install any software on your computer.

To write and execute code in a Colab notebook, simply click on a cell and then either type or paste your code into it. Once you have your code ready, press SHIFT+ENTER or CLICK on the PLAY ICON on left side of the cell to run the code! (like the image above) Try it out yourself by writing some code in the cell below and then pressing SHIFT+ENTER:

print("Hello world!!!")
Code language: PHP (php)

Whenever you run a code cell in Colab, any output from that code will be shown directly beneath the cell (as seen above). If no output is produced when you run a cell (i.e., if there are no print statements), then nothing will be shown beneath the cell when it is executed.

Congratulations! You’ve just created your first Google Colaboratory notebook. Now let’s take a look at some of the things you can do with it.

Adding Text cells

In addition to coding cells, there are also text cells in Colaboratory notebooks. Text cells allow you to add commentary or documentation about your code without having to actually write any code.

add some text

To insert a text cell beneath an existing cell, simply click on the cell and then press ESCAPE followed by B (or CLICK on +TEXT in toolbar). You should now see an empty text cell beneath your selected cell:

# This is a text cell
Code language: PHP (php)

Just like with coding cells, you can press SHIFT+ENTER or CLICK on PLAY ICON to render your text cell once you’re finished writing in it:

# This is a rendered text cell
Code language: PHP (php)

Running Code on GPU/TPU

If you want to run your code on a GPU or TPU (which is recommended for most machine learning tasks), all you have to do is specify that in the notebook settings.

To do this, click on the “Runtime” menu item and select “Change runtime type.” Then select either “GPU” or “TPU” from the “Hardware accelerator” drop-down menu.

Change GPU

Sharing notebooks with others:

Colaboratory makes it easy to share your notebooks with other people so that they can view them and even execute them themselves if they want to.

To share a notebook, simply click on the “Share” button at the top of the screen and choose who you want to have access to it (e.g., specific people or anyone with the link).

Share colab

Google Colaboratory is a cloud-based Jupyter Notebook environment that makes it easy to write and execute Python code. With Colab, you can share your notebooks with others and run them on GPUs or TPUs . You can also use Colab to collaborate with others on projects

Andy Avery

I really enjoy helping people with their tech problems to make life easier, ​and that’s what I’ve been doing professionally for the past decade.

Recent Posts