Free notebooks: Google Colab and Kaggle
Set up a free data science workspace in your browser with Google Colab and Kaggle Notebooks. Run code, bring in your data, install packages, use a GPU only when needed, and avoid the habits that lose work.
You will set up a free data science workspace in your browser, run your first code, upload a file, and learn the habits that stop you losing work. You need a Google account (for Colab) and an email address (for Kaggle). A phone or a basic laptop is enough, because the computing happens on remote servers.
A notebook is a document made of cells. Some cells hold code, some hold text. You run code cell by cell and the output (numbers, tables, charts) appears right below it. This is why data scientists love notebooks: you can try an idea, see the result and explain it in one place.
Colab or Kaggle?
Two free options
| Feature | Google Colab | Kaggle Notebooks |
|---|---|---|
| Sign in with | Google account | Kaggle account (email or Google) |
| Free GPU | Yes, with usage limits that vary | Yes, with a weekly quota |
| Datasets | Upload files or mount Google Drive | Huge library built in, attach with one click |
| Files after the session | Deleted unless saved to Drive | Saved versions of the notebook; outputs kept |
| Best for | Quick experiments, sharing a notebook with a link | Practising on real datasets, competitions, learning courses |
Both are free at the time of writing (2026), but limits on GPU time, memory and session length change, and are not guaranteed. Check each site's help page for current numbers. For this track, either works. Use Colab if you like Google Drive, and Kaggle if you want ready datasets.
Start with Google Colab
Your first notebook
- 1Open colab.research.google.com and sign in with your Google account.
- 2Click New notebook. Click the title at the top-left and rename it to
my-first-notebook.ipynb. - 3Click inside the first code cell, type
print("Hello, data science")and press Shift+Enter. This runs the cell and moves to the next one. - 4Click + Text to add a text cell. Double-click it to edit. Text cells use Markdown:
# Headingmakes a heading. - 5Open the Runtime menu and choose Run all to run every cell from top to bottom. You will use this to check that your notebook works from scratch.
import sys
import pandas as pd
import numpy as np
print(sys.version)
print("pandas", pd.__version__)
print("numpy", np.__version__)Colab already has pandas, NumPy, matplotlib and scikit-learn installed. This cell prints their versions, so you know the environment.
Your notebook is saved to your Google Drive automatically (in a folder called Colab Notebooks), but the running session is temporary. If you leave it idle for a while, or close the tab for long, the session ends and everything in memory and in the session's file storage is lost.
Getting files in
A data science notebook needs data. There are three common ways in Colab.
# Option 1: upload from your computer (files vanish when the session ends)
from google.colab import files
uploaded = files.upload() # opens a file picker
print(list(uploaded.keys()))After you choose a CSV, it is saved in the notebook's working folder. Read it with pd.read_csv("your_file.csv").
# Option 2: mount Google Drive (files stay in your Drive)
from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
df = pd.read_csv('/content/drive/MyDrive/data/sales.csv')
df.head()A pop-up asks you to allow access to your Drive. Put your CSV in a folder named data first, or change the path.
# Option 3: download from a public URL (replace the link)
!wget -q -O sales.csv "https://example.com/path/to/sales.csv"
!ls -lh sales.csvA line starting with ! runs a shell command inside the notebook. The link above is only a placeholder; use a real direct CSV link.
Installing packages and using a GPU
!pip install -q seabornUse !pip install in a cell. Packages you install vanish when the session ends, so keep this line at the top of your notebook.
Turn on a GPU (only when you need it)
- 1Open Runtime, then Change runtime type.
- 2Choose a GPU or TPU option if one is offered, then Save. Leave it on CPU for pandas and scikit-learn; you only need a GPU for deep learning later in this track.
- 3Run
!nvidia-smiin a cell. If it prints a table with a GPU name, the GPU is active. If it says the command is not found, you are on CPU.
GPU time is limited and shared. Switch back to CPU when you are not training neural networks, and close notebooks you are done with, so you do not use up your quota.
Kaggle Notebooks
Your first Kaggle notebook
- 1Go to kaggle.com and create a free account.
- 2Open Datasets and search for a dataset, for example a small CSV about house prices. Open it and click New Notebook.
- 3The dataset is already attached under
/kaggle/input/. Run the starter cell to list the files, then read one with pandas. - 4Use the right-hand Notebook options or Settings panel to choose an accelerator or turn internet on or off. Kaggle may ask you to verify your phone number before enabling GPU or internet.
- 5Click Save Version and choose Save & Run All to store a clean, top-to-bottom run.
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))This is the default first cell Kaggle gives you. Copy a printed path into pd.read_csv(...).
The Kaggle Learn section (kaggle.com/learn) has short free courses on Python, pandas and machine learning that run in the same notebook interface.
Habits that save you pain
Notebook checklist
- Put all imports and installs in the first cell.
- Run Restart session and run all before you share or submit. If it fails, your notebook only worked because of cells you ran out of order.
- Name notebooks clearly:
churn-eda-v1, notUntitled17. - Never put passwords or API keys in a notebook you will share.
- Do not upload personal data (phone numbers, Aadhaar numbers) to a public notebook or dataset.
- Copy results you need (a trained model, a cleaned CSV) to Drive or download them before the session ends.
The hidden-state trap
Cells can run in any order, and a notebook remembers what you ran, not what is on screen. If you delete a cell that defined df, the name df still exists in memory and later cells still work, until the session restarts and they break. Run all from the top regularly.
I am running a Python notebook in [Google Colab / Kaggle]. This cell fails:
```
[paste your code]
```
Error message:
```
[paste the full error]
```
Explain in simple English what the error means, point to the exact line that causes it, and show the corrected code. Then tell me one way to avoid this error next time.What to expect: The answer should name the line, explain the cause (for example a wrong file path or a missing import) and give runnable code. Re-run it yourself rather than trusting it.
Try it: Make your first analysis notebook
In Colab or Kaggle: (1) add a title text cell, (2) create a small DataFrame with the Brew & Bean menu using a Python dictionary with columns name and price (Espresso 120, Cappuccino 180, Cold Brew 220), (3) print the average price, (4) add a text cell explaining what you found, (5) use Restart and run all, then save or share the link.
Key takeaways
- A notebook mixes code, output and explanation in cells; run a cell with Shift+Enter.
- Colab and Kaggle are free browser notebooks; both have usage limits that change, so check their help pages.
- Colab sessions are temporary: save files to Drive or download results, and keep
!pip installlines at the top. - Kaggle has built-in datasets under
/kaggle/input/and saves versions of your notebook. - Use Restart and run all to catch hidden-state bugs before sharing.
Check yourself
Finishing the quiz marks the lesson as done.
1. You close Colab for a long time and come back to find your uploaded CSV missing. Why?
2. How do you run a shell command such as pip install seaborn inside a notebook cell?
3. Where do files from a dataset you attach to a Kaggle notebook appear?
4. Your notebook works on screen but a friend says it crashes on a clean run. What is the likely cause?
5. When should you switch a free notebook to GPU?
Saved on this device. Create a free account to keep it on every device.
Practise this with Sam
A real mock interview, out loud, with an honest scorecard. Free to start.