All lessons

Hello, Python · step 1 of 22

Printing & your first program

7 minMake Python speak: your very first line of code.

A program is a list of instructions

Python reads your code from top to bottom and does what each line says. The first instruction almost everyone learns is print() — it shows whatever you put inside the parentheses.

print("Hello, world!")

Text lives inside quotes

Anything wrapped in quotes is a string: text Python treats as characters instead of code. Write print(Hello) with no quotes and Python goes looking for something named Hello, does not find it, and stops with a NameError.

Errors are part of the job

When a line does not make sense, Python prints a traceback. Read the last line first — that is the real message. Programmers create errors all day long; the skill is reading them, not avoiding them.

Remember this

  • print(...) shows a value on the screen
  • Quotes turn text into a string
  • Read the last line of an error message first

Quick quiz

Three questions. 3 correct answers and you have the idea — you can retry as often as you like.

  1. 1. Which line correctly prints the word Hello?

  2. 2. What does print() do with the value inside the parentheses?

  3. 3. What happens when you run print(Hello)?

Answer all three to check them.

Now write it yourself

0/2 passed
1

Practice 1

Print the phrase `Hello, Python!` on one line.

practice_1.py
2

Practice 2

Print two lines: first `BuildHer`, then `Let's code.`

practice_2.py

Finish with two of three quiz answers correct and every exercise passing, and this lesson is marked complete.