Quest 1 · about 20 minutes · 170 XP

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.

How this page works
  1. Find a dark box marked Type your code here. That's your code box.
  2. Click inside it and type Python. You write every line yourself.
  3. Press the yellow ▶ Run button.
  4. 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:

print("Hello")
printThe command. Its name says what it does.
( )Brackets hold what you give the command.
"Hello"Text goes inside quotes. Python shows it without the quotes.

Quest 1 · Press the button

10 XP

One 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 XP

Click 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.

What does print(2 + 2) show?
What does print("2 + 2") show?

Quest 3 · Pocket calculator

15 XP

How 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.

Two rules that catch most beginner bugs

Quest 4 · Bug hunt: the lonely quote

20 XP

Run 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 XP

Run 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.

A program ends with print("Done!"). What does that line do?
Which of these three lines has a bug?

Boss · Build a name banner

40 XP

Write 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.

Final check · 6 questions

What did you learn?

Answer from memory. No scrolling up! At the end you get your score and a list of what you know.

1. What does print do?
2. Which line shows the word Hello?
3. What does print(10 * 3) show?
4. You see a NameError. What is the most likely cause?
5. How many lines does this show? print("A") print("B") print("C"), each on its own line.
6. Which quotes are correct?

Badge: First Words

0 / 16 quests done

Finish every quest and the final check to unlock it.

What you can do now

Keep the Python cheat sheet handy. It grows with every quest.

Watch next (best source)

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.

Stuck?

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