What we're doing today
By the end of this session, you will have opened a tool in your web browser, typed one short line, and made the computer say something back to you. That is the entire goal. If you have never written code in your life and you are not sure if you are in the right place — you are. This page assumes you know nothing, and I will go slow.
It is going to feel a little strange the first time. The screen will look unfamiliar. You will second-guess what to click. That passes. Every person you know who writes code sat exactly where you are sitting now.
What we are about to use
The tool we are going to use is called Google Colab. Colab is a website. You open it the same way you open Gmail or YouTube — you type the address into your browser and sign in with a Google account. There is nothing to install on your laptop. No downloads, no setup files, no scary black screens. If your computer can open Google Docs, it can run Colab.
Why are we using a website instead of installing things properly? Because in your first week, the only thing I want standing between you and your first program is a Google sign-in. Installing Python on your own laptop is a separate skill, and we will do that together at the end of Week 2. For now, the simpler the better.
If you already have Python installed on your laptop, I am still asking you to use Colab for this first assignment. It keeps everyone in the cohort on the same page.
What a notebook is
The thing you are about to open in Colab is called a notebook. The word is borrowed from a real paper notebook on purpose. Like a paper notebook, it is a single document where you can write things down. Unlike a paper notebook, some of the things you write down can be run by the computer.
A notebook is made up of stacked rectangles called cells. Think of a cell as one small box on the page. There are two kinds of cells. A text cell is for writing notes to yourself or to someone reading later — like the sentences in this very lesson. A code cell is for typing Python. When you run a code cell, the computer reads what you typed, does what you asked, and shows the result right underneath that same box.
If you have used Google Docs, the feel is similar. A file in your browser. It saves itself. You can come back tomorrow and it will still be there. The difference is that some of the boxes in this document are alive.
Opening Colab for the first time
Let's actually do it. Read the step, then do it, then come back for the next one. Don't rush.
- Open a new tab in your browser and go to colab.research.google.com.
- Sign in with a Google account. Use one you will still have access to in six months — not a school account that expires, not one you barely remember the password to.
- A welcome window may pop up. Close it. Then click File at the top-left, and from the menu that drops down, click New notebook.
A new tab will open. In the middle of the page you will see a single grey box with a small play button on its left side. That grey box is a code cell. That is where Python lives.
Your first line of Python
Click once inside the grey box so your cursor lands inside it. Now type exactly this, character for character:
print("Hello.")A few things matter about what you just typed. The brackets must be the round ones, not square. The quotes must be the straight kind that look like " — not the curly ones that some apps autocorrect to. If you copy-pasted from a chat app and the quotes look slanted, delete them and retype them inside Colab.
Now run the cell. There are two ways. Either click the small play button on the left edge of the cell, or, with your cursor still inside the cell, hold the Shift key and tap Enter. Shift + Enter is the keyboard shortcut you will use a hundred times this term. Learn it now.
The first run is slow on purpose
The first time you run any cell in a fresh notebook, you will see a spinning circle for somewhere between ten and twenty seconds. Nothing is broken. What is happening is this: Google is starting up a small computer for you, somewhere in one of their data centres, and connecting it to your notebook. After it is awake, every cell you run after that will be almost instant.
When the spinner stops, this is what you should see appear just below your cell:
Hello.That is your first program. You wrote it. The computer did it. Take a breath.
What actually happened
In the time it took to spin and respond, three things happened in order. Google gave you a temporary computer over the internet. That computer read your line of Python and ran it. It sent the answer back to your browser, which showed it under the cell.
That loop — type something, run it, look at what came out — is the entire job. Everything else in this course is the same loop with bigger and more interesting code inside the cell.
Give your notebook a real name
Look at the top of the page. Your notebook is currently named something like Untitled0.ipynb. That is the default Colab gives every new file, the same way a phone names a new contact "No Name" until you fill it in. Click on that name. A small text field opens. Change the name to:
pysprout-wk00-first-notebookPress Enter to confirm. The new name sticks.
You do not need to hit save. Colab is constantly saving your notebook to a folder in your Google Drive called Colab Notebooks. Close the tab, come back in three days, sign in, and your notebook will be exactly where you left it.
Sharing it back to me
For this first week's submission I need two things from you.
The first is a screenshot of your notebook with both the code and the output visible in one image. On a Mac, hold Cmd + Shift + 4, then drag a box around the part of the screen you want. On Windows, press Win + Shift + S and do the same. The screenshot lands on your desktop or clipboard.
The second is a share link. On the top-right of your notebook page, click the Share button. A window opens. Look for the section labelled "General access". It probably says "Restricted" — that means only you can open the file. Click it and change it to "Anyone with the link". Make sure the role on the right is set to Viewer, not Editor. Click Copy link.
Paste both the screenshot and the link into the Week 0 submission form. That is the whole assignment.
Common slip-ups
These trip nearly everyone the first time. None of them mean you are bad at this. When you hit one, you will recognise it from this list and fix it in seconds.
- The cell spins forever and nothing prints. Colab probably lost its connection. Go to the top menu, click Runtime, then Reconnect. If that does not help, click Runtime then Restart session, and run the cell again. Colab also disconnects you after about 90 minutes of doing nothing — that is normal, not your fault.
- You see a "Connect" button in the top-right and nothing happens when you run. That means Google has not given you a computer yet. Click the Connect button and wait for the small green tick to appear next to it. Then run the cell again.
- You ran it but you cannot find the output. The output appears in a slightly indented block directly below the cell — not on a new page, not at the bottom of the screen. Scroll a little. If there is genuinely nothing there, check three things. Did you press Shift + Enter, and not just Enter? Are your quotes the straight kind
"and not the curly kind? Did you remember the closing round bracket)at the end? - You typed
print "Hello."and got a red error. The round brackets are not optional. Python needsprint("Hello."), with the text tucked inside the brackets.
If none of those fix it, take a screenshot of what you see on your screen and drop it in our cohort channel. I would much rather you ask in the first hour than sit stuck for three days. That is the deal we have.
See you in Week 1.