First Words: make the computer talk
Every programmer's first program makes the computer say something. Today you write yours, hunt two bugs, beat a boss, then take a final check to see what you learned.
- Find a dark box marked Type your code here. That's your code box.
- Click inside it and type Python. You write every line yourself.
- Press the yellow ▶ Run button.
- Your result shows in the box below it, and you get a message: done or try again.
No setup needed. Python runs right here on the page.
A program is a list of instructions
A computer does nothing on its own. A program is a list of instructions, and Python reads them one line at a time, top to bottom.
Your first instruction is print. It shows text on the screen.[1] It has three parts:
Quest 1 · Press the button
10 XPOne line of Python is already in the code box below. Press ▶ Run and look at the result box. Python shows Hello, world!
Need a hint?
Don't change anything. Just press the yellow Run button under the dark box.
Quest 2 · Make it yours
15 XPClick in the code box. Delete world and type your name, so it says Hello, Ana! (with your name). Keep the quotes and brackets. Then press Run.
Need a hint?
Only change the words between the two quotes. The line should still start with print(" and end with ").
Quotes change everything
Inside quotes, Python treats things as plain text. That text is called a string.[2] Without quotes, Python reads numbers as numbers and does the math.[3]
Single quotes work too: 'Hi' and "Hi" are the same.[2] Just make both sides match.
Try to answer without running anything. Guessing first, then checking, is how memory sticks.
print(2 + 2) show?No quotes, so Python does the math and shows 4.
print("2 + 2") show?Quotes make it a string. Python shows the text exactly as written: 2 + 2.
Quest 3 · Pocket calculator
15 XPHow many hours are in a year? Make Python work it out: 365 days times 24 hours. In Python, * means times.
Don't type the answer yourself. Let Python do the math.
Need a hint?
Click between the two brackets and type 365 * 24. No quotes, because quotes would make it text.
Bugs are normal. Errors are clues.
A bug is a mistake in code. When Python hits one, it stops and shows an error. The error is not a punishment. It tells you what went wrong and on which line. Pros read errors all day.
- Every opening quote needs a closing quote. Same for brackets.
- Python is picky about capitals.
printworks.Printdoes not.
Quest 4 · Bug hunt: the lonely quote
20 XPRun this first and read the error. Then fix the code so it shows I am learning Python.
Real Python says SyntaxError: unterminated string literal here. That means a string never got its closing quote.
Need a hint?
Count the quotes. There is only one. Add a second " right after the word Python.
Quest 5 · Bug hunt: the big letter
20 XPRun it, read the error, fix it.
A NameError means Python doesn't know a word you used. Often it's a typo or a wrong capital letter.
Need a hint?
Look closely at the very first letter of the line.
Read code like a pro
Good coders read code as much as they write it. Answer these in your head first.
print("Done!"). What does that line do?print only shows text on the screen. It doesn't save or send anything. Programs often use it to say a task is finished.
The third line opens a quote and never closes it. Single quotes in the first line are fine.
Boss · Build a name banner
40 XPWrite three print lines that make a banner like this, with your own name in the middle:
********** Ana **********
Top and bottom lines must match. Each print makes a new line. Start from an empty box.
Need a hint?
Write one print("...") per line, so three lines in total. Press Enter to start a new line. The first and last lines are the same row of stars.
What did you learn?
Answer from memory. No scrolling up! At the end you get your score and a list of what you know.
print do?print shows things on the screen. That's all it does.
Text needs quotes, and print needs a small p.
print(10 * 3) show?No quotes, so Python calculates. * means times.
NameError. What is the most likely cause?NameError means Python doesn't know a word, often a typo or a capital letter. A missing quote gives a SyntaxError.
print("A") print("B") print("C"), each on its own line.Three prints, three lines, shown top to bottom.
Single or double both work, but both sides must match.
Badge: First Words
0 / 16 quests done
Finish every quest and the final check to unlock it.
What you can do now
- Show text with
print("...") - Tell text (in quotes) from numbers (no quotes)
- Do math with
+ - * - Read an error and fix a missing quote or a wrong capital
Keep the Python cheat sheet handy. It grows with every quest.
CS50P Lecture 0 (Harvard, free). Watch the first part, about print and strings. You'll recognize everything from today.
Also: the official Python tutorial, chapter 3.
Open Need a hint? under any quest. After two tries, a Show answer button appears. Still stuck? Ask real people at r/learnpython or the Python Discord. Both welcome beginners.
Sources: [1] Python Tutorial 3.2 · [2] Python Tutorial 3.1.2 Text · [3] Python Tutorial 3.1.1 Numbers