Lesson 1 of 34 · 0 of 2 exercises solved
Hello, World!
Your first program prints a line of text. It confirms Python is installed correctly and shows you how to run a script.
In Python, printing to the takes exactly one line. No , no definitions, no semicolons. The print() outputs text (or any value) to standard output and appends a newline automatically.
print("Hello, World!")Save that as hello.py and run it with python3 hello.py. That's your first program. print() is more flexible than it looks: it accepts multiple and lets you customize the separator and line ending.
# Multiple arguments — joined with a space by default
print("Hello,", "World!") # Hello, World!
# Custom separator
print("2024", "01", "15", sep="-") # 2024-01-15
# No newline at end
print("Loading", end="...")
print("done!") # Loading...done!
# Print numbers and booleans directly
print(42)
print(3.14159)
print(True)Common question
Is a program that only prints one line a real program?
A program is text a machine can run. The smallest one worth writing is the one that proves you and the machine agree on the basics: where the file goes, how you run it, where the output shows up. Hello, World is a handshake, and every bigger program depends on that handshake working.
It also teaches the core habit: write one thing, run it, look at the result, then change one thing and run it again. Running early and often matters more than any language feature, and it starts with a single print.
Source: Kernighan and Ritchie opened The C Programming Language (1978) with exactly this program, and most languages since have followed.
Common mix-ups
Each of these sounds reasonable. Think about why it is wrong, then open the explanation.
A real program has to do something useful, and printing a greeting does nothing.
Since print is built in, I didn't really write anything.
A program with no input can't be tested, so it can't be called correct.
Practice
Your turn. Change the program so it prints exactly Hello, ScholastiCoder! on one line, then on a second line print the number 42 without quotes.
Say hello, then count
print("Hello, World!")
Press Run to try your code, then Check answer to grade it.Use the sep argument to print a date from three separate numbers so the output reads 2026-09-05. Then use end to print Loading and done! on the same line, joined by three dots.
Separators and endings
year = 2026
month = "09"
day = "05"
# 1. Print year-month-day using sep
# 2. Print "Loading...done!" using two print() calls and end=
Press Run to try your code, then Check answer to grade it.Check yourself
What does print("a", "b", "c") output?
Tip: use the ← and → keys to move between lessons.