Hello, Python — talking to the screen

Every morning the school notice board shows one message at a time: date, event, reminder. print() is your notice board. Whatever you put inside the brackets is what a human (or a log file) will read. Until you print, the program may have calculated a brilliant answer in silence.

School notice board

print() is how your program speaks.

You will be able to

  • Use print() to show text and numbers
  • Mark text as a string with quotes
  • Print several values on one line with commas

print is an instruction, not a decoration

print is a function: a named tool. The round brackets hold what you want to show. Think of a loudspeaker: print("Sports Day") is you speaking into it.

Beginners often write a calculation and forget to print it. The computer did the work — and showed nothing. If you cannot see it, you cannot check it.

Strings wear quotes

Hello without quotes is a name Python will hunt for in memory (a variable). "Hello" is a string: a packet of characters. Quotes are the wrapping paper that says “this is text, not a name”.

You may use double quotes "like this" or single quotes 'like this'. Pick one style and stay consistent in a file. If the text itself contains an apostrophe, double quotes are easier: "Asha's bag".

Several things in one print

Separate values with commas. Python inserts a space between them: print("Score", 10) shows Score 10. This is how you mix a label (string) with a number.

Each print ends by moving to a new line. Three print calls give three lines on the notice board — useful for assembly messages that must be readable from the back of the hall.

Label plus number

print("House points", 120)
print("Captain", "Meera")

Words that matter

String
Text in quotes — a sequence of characters.
Function call
A name followed by brackets, like print(...).
Output
What the program shows on the console.

Common mistakes

Avoid: print(Hello) without quotes.

Do this: print("Hello") unless Hello is a variable you already created.

Avoid: Forgetting the closing quote or bracket.

Do this: Count pairs: every " needs a matching ", every ( needs a ).

Example program — Morning assembly message

Run it, then change the name and the event. The notice board should still make sense.

Python sandboxlesson://workspace
console

Edit the example, press Run, then Build if you want a compile check.

build

Press Build to compile.

Your turn — Write a welcome banner

Print a line that includes the word Welcome (for example Welcome, Blue House).

Python sandboxlesson://workspace
console

Edit the example, press Run, then Build if you want a compile check.

build

Press Build to compile.

Self-assessment

Check your understanding before you mark the lesson complete.

1. Which line prints the word Hello?
2. print("A", 1) typically shows…
3. A string is…

Progress is stored in a browser cookie on this device.