π§ Start Here
Scroll down to complete this route
ROUTE: The Colab Warm-Up
- RouteID: 002
- Wall: Basecamp; Getting Comfortable With Python
- Grade: 5.7
- Estimated time: 45β60 minutes
- Prereqs: None (no prior Python or Colab experience required)
Route overview
This route introduces Google Colab, the interactive notebook environment we will use across CHEM169/269.
For years, scientists wrote code in scattered scripts and kept notes separately (Figure 1). Jupyter notebooks changed the workflow: they combined text, code, data, and results in one place β an experimental bench for programming. Google Colab takes that bench into the cloud. There is nothing to install, notebooks run anywhere, and sharing is as simple as a link. It lets us focus on ideas rather than setup.
In this route, you will build your first notebook, write and run Python cells, upload files, connect to your Google Drive, and try asking Gemini for help. Youβll reuse these skills in almost every wall of the course.
Learning objectives
By the end of this route, you should be able to:
- Create and rename a Colab notebook.
- Use markdown and code cells appropriately.
- Upload a local file and read it in Python.
- Mount Google Drive and read a file from your Drive.
- Ask Gemini for help and incorporate its suggestions into your notebook.
Part A β Start the Notebook
There are two ways to create a new Colab notebook. You can use either one in this course.
Method 1 β Start from the Colab website
- Go to: https://colab.research.google.com
- Click New Notebook.
- Rename your notebook to:
Route_<RouteID>_<RouteNameClean>_<LastName> - Insert a text (Markdown) cell at the top containing:
# Route: The Colab Warm-Up Name: Your Name Date: YYYY-MM-DD
Method 2 β Create a Colab notebook directly inside Google Drive
This method is useful if you want your work organized by wall or route.
- Go to Google Drive.
- Navigate to the folder where you want this notebook to live.
- Click New β More β Google Colaboratory.
- A new notebook will open. Rename it to:
Route_<RouteID>_<RouteNameClean>_<LastName> - Add the same Markdown header from Method 1.
Part B β First Python Cells
This part introduces the basic mechanics of writing and running Python cells in a Colab notebook. You will create three short cells: a simple calculation, a small data structure, and a mini-challenge.
Cell 1 β A tiny calculation
Create a code cell and run the following:
# Estimate how many minutes there are in a year
days_per_year = 365
hours_per_day = 24
minutes_per_hour = 60
minutes_per_year = days_per_year * hours_per_day * minutes_per_hour
print(f"There are about { minutes_per_year } minutes in a year.")
This introduces:
- variables
- basic arithmetic
- formatted output
Cell 2 β A small list and loop
Create another code cell:
# Three short facts about yourself
facts = [
"I enjoy climbing.",
"I'm curious about AI/ML.",
"I'm taking CHEM169/269 this quarter."
]
for fact in facts:
print("β’", fact)
This introduces:
- lists
- iteration
- structured output
Feel free to edit the facts to make them true for you.
Cell 3 β extra practice
If youβd like a slightly richer challenge, try this:
# Optional: estimate how many minutes you've been alive
age_years = 21 # Replace with your age
minutes_alive = age_years * minutes_per_year
print(f"I have been alive for roughly {minutes_alive:,} minutes.")
This reinforces how Python reuses variables across cells.
Part C β Upload and read a file
1) On your computer, create a text file called hello.txt with the contents:
This is a file uploaded to Colab!
2) In a new code cell, upload the file:
from google.colab import files
uploaded = files.upload()
Use the file picker to choose hello.txt.
3) In another code cell, read and print the contents:
with open("hello.txt", "r") as f:
contents = f.read()
print(contents)
You should see the text from hello.txt printed in the notebook.
Part D β Mount Google Drive
In this part, you will connect your notebook to your Google Drive and read a file from there.
- In the right-hand panel in Colab, open the Gemini (or βAIβ / βHelpβ) sidebar if available.
- Ask a question such as: β βHow do I mount Google Drive in Google Colab and read a text file from it?β
- Read the response and identify the key steps.
If you get stuck, you may use the snippet below:
from google.colab import drive
drive.mount('/content/drive')
After mounting:
4) In your Google Drive, create a text file (for example drive_hello.txt) containing:
This is a file saved in Google Drive!
5) In Colab, write a code cell to read and print this file. A typical path looks like:
file_path = "/content/drive/My Drive/drive_hello.txt"
with open(file_path, "r") as f:
content = f.read()
print("File contents:")
print(content)`
Adjust file_path to match the actual location of your file in Drive.
Optional Hold (extra practice)
Add another code cell where you ask Gemini:
"Explain the difference between a code cell and a markdown cell in Colab as if Iβm new to programming."
Summarize the answer in your own words in a markdown cell.
The Dyno (optional, for extra difficulty)
Write a small Python function that prints a personalized message using a name and favorite food:
def introduce(name, favorite_food):
print(f"My name is {name} and I really love {favorite_food}.")
introduce("YourName", "YourFavoriteFood")
Then, modify it so that it asks the user for input using input() and uses their answers.
Deliverables
Please submit the following two items:
1. A completed Jupyter notebook (.ipynb)
-
The notebook should run top-to-bottom without errors.
-
It should include your code and any brief comments you added while working.
-
Please follow this file naming convention β lastname_firstname_RID_002_code.ipynb
- The RID stands for βRoute IDβ. This would be route #002.
How to download from Google Colab:
-
In Colab, click File β Download β Download .ipynb
-
This will save the notebook to your computer.
2. A short logbook entry (plain text, ~5β10 sentences):
- Briefly describe:
- what was tricky or confusing
- what helped you get unstuck
- one thing you learned about working with real data
- File naming convention β lastname_firstname_RID_002_logbook.txt
- Focus on clarity and completeness.
Submission
For now, submit your files by uploading them to the Google Form below:
Please upload both: - your .ipynb notebook - your logbook file
Make sure filenames follow the naming conventions above.
We will fine-tune our submission system as the course moves along. Thank you for your patience as a valued member of the CHEM 169/269 Climbing Gym.
π Route Complete!
Great work!