Open In App

Google Colab

Last Updated : 24 Jul, 2025
Comments
Improve
Suggest changes
1 Likes
Like
Report

Google Colab is a cloud-based, interactive notebook platform that combines code, text, images, equations, and more in a single document. It’s designed to make data science, machine learning, and collaborative Python programming accessible for everyone, not just developers. It is widely used by data scientists, analysts, and machine learning enthusiasts due to its unique features and advantages.

Why Google Colab?

  • Cloud-based notebook interface: Users can access Google Colab from a web browser.
  • Pre-installed Libraries: Google Colab comes with several pre-installed libraries and packages, such as NumPy, Pandas, Matplotlib.
  • Real-time Collaboration: It offers a collaborative environment for individuals and teams to work on projects, data analysis, machine learning tasks, and more.
colab-real-time-collaboartion
Colab real-time collaboration
  • Free Computing Resources : It provides access to powerful resources such as GPUs and TPUs making it ideal for or running computationally intensive tasks without relying on your local machine's hardware.
  • Integration with Google Drive and Github : It allow users to save, share and store their Colab notebooks directly in the cloud.
colab-integration
Colab gitHub & drive integration

Understanding the Colab Interface

1. Editor

The editor is where you write your code. It also includes a number of features to help you write and debug your code, such as code completion, syntax highlighting and error messages.

Code cells

  • The area where you can able write and execute the program.
  • Click the Play icon in the left gutter of the cell;
  • Type Cmd/Ctrl+Enter to run the cell in place;
  • Type Shift+Enter to run the cell and move focus to the next cell (adding one if none exists); or
  • Type Alt+Enter to run the cell and insert a new code cell immediately below it.
colab-code-cell
Code cells in google colab

Text cells

  • The area where you can able write any text.
  • It supports Markdown syntax.
  • You can also add math to text cells using LaTeX to be rendered by MathJax. Just place the statement within a pair of  $  signs. For example:$\sqrt{3x-1}+(1+x)^2$ becomes √(3x-1) + (1+x)2.
Colab text area which support Markdown

Additionally you can add new cells by using the + CODE and + TEXT buttons that show when you hover between cells. These buttons are also in the toolbar above the notebook where they can be used to add a cell below the currently selected cell. This makes your code well organized and proof helpful for other people whom you share.

colab-overview
Adding & moving cells using top toolbar in Google colab
2. Runtime

The runtime is where your code is executed. It includes a number of features to help you run your code.

Colab runtimes are servers that are used to execute your code such as :

  • GPU: Graphical Processing Unit(Capable of enhancing your graphical interface.)
  • TPU: Tensor Processing Unit(Much powerful powerful custom-built processors to run the project made on a specific framework, i.e. TensorFlow.)
  • CPU: Central Processing Unit(It manage all your functions such as calculations and input/output of the computer.)

To select runtime, navigate to the Runtime menu and select Change runtime type according to the usability.

runtime-navigation
select runtime type from runtime menu
change-runtime-type
Change the required runtime type
colab
Supports all 3 programming languages

It Supports all three programming languages including Python 3,R and Julia.

Geeting Started with Google Colab

It is a cloud based interface as specified earlier; you can simply get started by the following:

1. Accessing Google Colab

  • Open your web browser and search for google colab and then simply click the first link provided which will redirect you to the Google Colab's welcome page.
Colab web browsing

2. Creating a Google Account (if needed) and Sign In

  • If you don't have one, simply create a Google account its absolutely free else sign in to your account.
Colab account sign-in

3. Create a New File / Notebook

  • You can simply click on the new notebook redirecting you to a new page to get started.
colab-newfile-creation
Colab new notebook creation
  • OR simply you can select the New notebook in the File menu.
Another method to create new notebook in Colab

4. Executing Code Cell

  • You can able to write your program within the code cell and can run the code to check your desired output.
code execution in google colab

Working with Google Drive in Google Colab

  • Open Google Colab and click on the Mount Drive button.
  • For accessing files in your Google Drive, use the "Mount Drive" button or run:
Python
from google.colab import drive
drive.mount('/content/drive')


mounting-drive
Mounting drive in Colab
  • Click on the Connect button to give Colab access to your Drive.
connecting-drive
connecting colab to drive
drive-mounted
google drive gets connected/mounted in collab

Accessing and Saving Notebook in Drive

Once you've linked your Drive to Colab, you can access and save notebooks from Drive directly within Colab.

To access a notebook from Drive

  • Click on the File menu and select Open Notebook.
accessing-notebook
access notebook from file menu
  • Click on the Drive tab and navigate to the notebook you want to open.
open-notebook
Open your saved notebook from drive

To save a notebook to Drive

  • Click on the File menu and hit Save your notebook.
save-file
save the notebook from file menu
  • Click on the Drive tab and navigate to the folder where you want to save the notebook and click on the Save button.
colab-notebook-in-drive
collab notebooks folder in drive
  • Colab automatically saves your notebooks to a “Colab Notebooks” folder in Google Drive.
saving-notebook
colab notebooks folder in drive

Share your Notebook

  • Click on the Share button in the top right corner of the notebook.
select share button
  • Enter the email addresses of the people you want to share the notebook.
share-your-notebook
share notebook using email address
  • Additionally you can upload or download your Notebook as .py or .ipynb format.

1. Upload Notebook

  •  Click on the File option and move down to find the Upload notebook to upload the files.
upload your colab notebook from file menu

2. Download Notebook

  •  Under the File menu you will aslo find the Download your file in .ipynb and .py formats.
download your colab notebook from file menu

Gemini in Google Colab?

As you Gemini is an AI-powered assistant, and it is embedded in Colab that helps you write, debug and understand code, automate data science workflows and generate insights all through conversational prompts and natural language instructions. It’s designed to make coding, analysis and collaboration easier for everyone, from beginners to experts.

Key Features of Gemini in Colab:

1. Conversational Coding Assistant

  • Code Generation: Describe what you want like “load and plot this CSV” and Gemini writes the code for you.
  • Code Completion: As you type, Gemini suggests code completions, making prototyping and learning faster.
  • Code Explanation: Select any code cell and ask Gemini to explain it in plain language.
  • Debugging: When errors occur, Gemini diagnoses issues and suggests or applies fixes.

2. Data Science Agent

  • Automated Analysis: Upload a dataset and describe your goals. Gemini generates code for data cleaning, visualization, modeling and more.
  • Insight Summaries: Gemini can summarize findings, highlight key features and create visualizations based on your data.
  • Workflow Automation: Gemini can handle multi-step tasks—like building and evaluating machine learning models without manual intervention.

3. Visualizations and Reporting

  • Instant Charts: Ask Gemini to “plot this data” or “show a correlation matrix,” and it generates clean, ready-to-use visualizations.
  • Automated Reports: Gemini can produce summary reports with key findings, charts and recommendations.

4. Refactoring and Code Transformation

  • Code Refactoring: Describe changes like “convert this regression to classification” and Gemini updates your code accordingly.
  • Multi-step Reasoning: Gemini can plan and execute complex workflows from start to finish.

5. Seamless Integration and Accessibility

  • Easy Activation: Gemini is available via the Gemini spark icon in Colab notebooks.
  • Collaboration: All collaborators in a notebook can use Gemini, ensuring consistent guidance and results.
  • Enterprise Support: Gemini features are available in both standard and enterprise Colab editions.

How to Use Gemini in Google Colab

  • Go to Google Colab and open or create a notebook.
  • Click the Gemini icon (spark) in the notebook interface.
Gemini
Accessing Gemini
  • Type your question or describe the coding/data task you want to accomplish.
Ask
Describe Task
  • Gemini will generate, explain or fix code in your notebook. Review and execute as needed.
Output
Output

Keyboard Shortcuts for a Better Colab Experience

These are some keyboard shortcuts that you can use to improve your Colab experience:

  • Ctrl + Enter : Run the current code cell.
  • Shift + Enter : Run the current code cell and move to the next one.
  • Ctrl + Z : Undo the previous action.
  • Ctrl + Y : Redo the previous action.
  • Ctrl + C : Copy the current cell or selected text.
  • Ctrl + V : Paste the copied cell or text.
  • Ctrl + X : Cut the current cell or selected text.
  • Ctrl + / : Comment/Uncomment the current line or selected text.
  • Ctrl + S : Save the current notebook.

Explore