Google Colab#

Section Title: Colaboratory

Google Colab (Colaboratory) is a cloud-based notebook for writing and executing Python code.

  • You need to sign into your Google account to execute code and save your notebook.

  • There’s no requirement to install any software on your computer.

  • Sharing your notebooks is easy, and Colab files are automatically saved to Google Drive.

Google Drive#

Google Drive is used for storing files in the cloud.

  • You can manage, modify, and share your files.

  • By default, you have 15 GB of free storage, but there are also options for paid storage, such as 100 GB, 200 GB, and so on.

  • Within your Google or Gmail account, you can access Google Drive and other applications by clicking on the Google Apps Icon, which has nine dots and resembles a square.

  • By clicking on +New in the upper left corner of your Google Drive (located underneath the Drive icon), you can:

    • Upload a folder or file to Drive

    • Create Google Docs, Google Sheets, Google Slides, Google Forms, etc.

    • When you click on the More Actions icon (three vertical dots on the right), you will see options to modify your folder.

    • You can move, download, share, rename, or delete your files and folders.

Installing Colab to your Google Drive#

You can easily create Colab notebooks on your Google Drive by installing Colab onto your Google Drive (not onto your computer).

  • Follow the following steps for installation:

    1. Click on +New in the upper left corner of your Google Drive (located underneath the Drive icon).

    2. Choose the More option at the end.

    3. In the new menu, if you see the Google Colaboratory icon, it means you already have Colab installed on your drive.

    4. If there is no Google Colaboratory icon, then click on Connect More Apps.

    5. Search for Google Colaboratory.

    6. Click on Google Colaboratory in the search results and install Colab on your drive.

The Google Apps icon is located in the upper right corner, while the + New button is found below the Drive symbol in the upper left corner. In the + New menu, you can access various Google products. For each file, you can use the three-dot menu on the right to download, share, delete, or organize the file.

Create a new Colab notebook#

Follow these steps:

  1. Click on +New in the upper left corner of your Google Drive (located underneath the Drive icon).

  2. Choose the More option at the end.

  3. In the new menu, click on Google Colaboratory.

Additionally, instead of using +New, you can right-click to access its contents.

Rename a Colab File#

  • There are two ways to rename a Colab notebook:

    • Use the More Actions icon (three vertical dots on the right).

    • Open the Colab notebook (the default name is Untitled0) and click on its name in the upper left corner, next to the Google Drive icon.

To rename a file, click on the three-dot menu and select Rename. The title of a notebook is displayed in the upper left corner, along with the .ipynb extension.

Share a Colab File#

To access the share options, you can do one of the following:

  1. Use the More Actions icon (three vertical dots on the right).

  2. Open the Colab notebook and click on Share in the upper right corner.


There are two ways to share a Colab notebook:

  1. Enter the Gmail address of the person you want to share the notebook with.

  2. Copy the link and share it, but change the last part from Restricted to Anyone with the link.


You have the following options to assign the person:

  • Editor: Can change everything in the document.

  • Commenter: Can write comments.

  • Viewer: Can download a copy of the file but cannot modify your original file

The Share button is located in the upper right corner. In the share window, you can enter the recipient's Gmail address. Using the Restricted option, you can also share the file with anyone who has the link. In the Access menu, you can choose the recipient's role as Editor, Commenter, or Viewer.

More Tools#

Theme#

There are three theme options:

  • light (white background)

  • dark (black background)

  • adaptive (color depends on time)

Follow these steps on the toolbar to change the theme: Tools –> Settings –> Theme

Power Level, and Kitty, Corgi, Crab#

These are some fun tools to make the notebook more fancy:

  • Go to Tools –> Settings –> Miscellaneous

  • You can adjust the power level to add sparks when you write or execute code.

  • You can add walking Kitty, Corgi, and Crab characters to your notebook.

  • In the tools menu bar at the top, you can use Settings to change the theme to either dark or light. Within the Miscellaneous section of the Settings, you can add characters such as Power Level, Kitty, Corgi, and Crab to your notebook.

Cells in Colab#

These are rectangular-shaped boxes that come in two types:

  • Text Cell: Used for writing explanatory text.

  • Code Cell: Used for writing and executing Python code.


  • By default, a new notebook contains one code cell.

  • You can add, delete, and move cells up or down.

  • A Colab notebook is essentially a list of cells.

Adding Cells#

You can add a text or code cell by using the +Code and +Text buttons on the toolbar (upper left corner).

  • You can use these buttons to add a cell below.

When you move the cursor to the upper (lower) middle of a cell, you will also see +Code and +Text buttons.

  • You can use them to add a cell above (below).

The + Code and + Text buttons are located in the upper left corner, under the File tab. You can also access the + Code and + Text buttons by moving the cursor to the middle of a cell. The cell menu is located on the right and includes icons for moving up/down, adding a link, commenting, and deleting.

Delete, Move and Comment#

When you click on a cell, a menu will appear in the upper right corner of the cell. Using this menu:

  • You can delete the cell.

  • You can move the cell up or down.

  • You can add a comment to the cell.

Short cuts#

  • A: Add a code cell above

  • B: Add a code cell below

  • shift+Enter: Execute a code cell