Skip to the content

Hello, world

Python · Unit 1: First steps

print() shows on the screen whatever you put inside the parentheses.

The text goes inside quotes, and each print() writes on its own line.

print("Hello, world")
print("I can code now")

Prints

Hello, world
I can code now

Numbers go without quotes, and if you write a calculation, Python does it.

With quotes, everything is text and comes out exactly as you wrote it.

print(2 + 3)
print("2 + 3")

Prints

5
2 + 3

print() can receive several things separated by commas.

It shows them on one line, with a space between each one.

print("I am", 17, "years old")

Prints

I am 17 years old

Exercises in this lesson

You do them in the app, which checks them on the spot and explains why.

  1. 1. Predict the output

    What does this code print?

    print("Hello")
    print("world")
  2. 2. Complete the code

    Fill in the blank so the program says hello.

    ___("Hello, world")
  3. 3. Predict the output

    What does this code print?

    print("My name is Emma")
    print("I am 20 years old")
  4. 4. Multiple choice

    What does this code do?

    print("10 + 5")
  5. 5. Multiple choice

    Which line shows the text Good morning?

  6. 6. Find the bug

    This program should greet Noah. Which line has the error?

    print("Hello")
    print(Noah)
  7. 7. Predict the output

    What does this code print?

    print("I will", "code")
  8. 8. Complete the code

    Fill in so it prints: Jack is 20

    print(___, "is", 20)
  9. 9. Put the lines in order

    Order the lines to print the ticket. First the title, then the price and the good trip at the end.

  10. 10. Predict the output

    What does this program draw?

    print("********")
    print("*", "Hello", "*")
    print("********")
Do this lesson

It opens in your browser. It is free and you do not need an account to start.

See all lessons →