Your First Program
Write your very first line of Python and make the computer say hello to the world.
Every programmer in history has started exactly where you are right now. The very first program almost everyone writes is called Hello, World! — and it is a tradition going back to the 1970s.
Your goal in this lesson: make the computer display a message on the screen. That is it. One line of code. Let's go.
See it in action
— step through the idea, then dive into the details below.Your First Python Program
Every programmer starts here — a tiny program that makes the computer display a message. One line of code, and you're officially a Python programmer.
#What is print()?
Python has a built-in command called print(). Think of it like a megaphone — whatever you put inside the parentheses, Python will shout it out onto your screen.
The parentheses () are how you hand something to a command. Everything inside is the message you want to display.
print() is like a megaphone
Imagine handing a note to a friend and saying "read this out loud." print() is that friend. You put your message inside the parentheses, and Python reads it out loud — onto your screen.
#Your First Line of Code
print("Hello, World!")When Python runs this line, it looks inside the parentheses, finds your message, and displays it. The output appears instantly below your code.
You just wrote a real, working Python program. Take a second to appreciate that.
#Why Do We Need Quotes?
The quotes around "Hello, World!" tell Python: this is text, not a command. In Python, a piece of text wrapped in quotes is called a string.
Without quotes, Python would think Hello is the name of something it should look up — and it would get confused and show an error.
Forgetting the quotes causes an error
``python print(Hello, World!) ` This will **crash** with a SyntaxError. Python sees Hello and World` as unknown names, not text. Always wrap your text in quotes.
#Single Quotes Work Too
print('Hello, World!')Python accepts both 'single quotes' and "double quotes" around strings. The output is identical. Most people pick one style and stick with it — but you can use either. Just make sure your opening and closing quote match!
#Printing Multiple Things at Once
You can print more than one item in a single print() call by separating them with a comma. Python will put a space between each item automatically.
print("Hello", "World", "from Python!")Print as many items as you like
There is no limit to how many items you can pass to print(). Each comma-separated value gets printed on the same line, separated by a single space. Great for mixing text and values later on!
#Printing Multiple Lines
print("Hello, World!")
print("I am learning Python.")
print("This is awesome!")Every print() call automatically ends with a newline, so the next print() always starts on a fresh line. You can stack as many as you need.
#Check Your Understanding
What will this code print? print("Python", "is", "fun")
Key takeaways
- `print()` displays text (and other values) on the screen.
- Text in Python must be wrapped in quotes — either single `'...'` or double `"..."` — to be treated as a string.
- Separate multiple items with commas inside `print()` and Python adds spaces between them automatically.
- Each `print()` call outputs on its own line.
- You just wrote real Python code — every expert started exactly here.
What does this code print?
print("Hello", "World", "from Python!")This code has a bug. What is wrong?
print(Hello, World!)Complete the code so it prints: Learning Python is fun
("Learning Python is fun")Put these lines in the right order so the program prints three lines: Hello!, I am learning Python., See you soon!
print("See you soon!")print("Hello!")print("I am learning Python.")Write a small program that introduces yourself. It should print three lines: your name, what you are learning, and one thing you are excited about. Use at least one print() call that has two items separated by a comma.
Try it live — edit the code and hit Run to execute real Python: