Module 4 of 13 · Google Colab: Cloud Computing for AI · Beginner

Basic Notebook Operations

Duration: 5 min

This module delves into the fundamental operations of Google Colab notebooks, which are essential for efficiently managing and executing AI projects. Understanding these operations is crucial for leveraging the full potential of cloud computing in your AI endeavors.

Creating and Saving Notebooks

Google Colab notebooks are cloud-based, allowing you to save and access your work from anywhere. To create a new notebook, simply go to the Colab homepage and click on 'File' > 'New notebook'. You can save your work automatically to Google Drive by clicking on 'File' > 'Save' or 'Save a copy in Drive'. This ensures that your progress is backed up and easily accessible.

# This is a simple Python code to demonstrate saving a notebook
from google.colab import drive
drive.mount('/content/drive')
# After running this, you will be prompted to authorize access to your Google Drive
# Once authorized, you can save your notebook to your Drive

Try it in Google Colab: Open in Colab

Mounted at /content/drive
Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth...
Enter the authorization code: 4/...

Running Cells

Cells in Google Colab can contain either code or markdown. To run a cell, click the play button to the left of the cell or use the keyboard shortcut Shift + Enter. This will execute the cell and move the cursor to the next cell. If you want the cursor to stay in the same cell after execution, use Ctrl + Enter.

# This code demonstrates running cells in Google Colab
print('Hello, Colab!')  # This will print the text to the output
# Click the play button or use Shift + Enter to run this cell
Hello, Colab!

💡 Tip: Always ensure your cells are running in the correct order, especially when dependencies exist between them. Misordered cells can lead to errors.

❓ How do you save a notebook to Google Drive?

❓ What keyboard shortcut moves the cursor to the next cell after running a cell?

← Previous Continue interactively → Next →

Related Courses