Hello, Python!
Your first program, run in a real Python interpreter that lives right here in the page. Change the code, press Run, and the browser actually executes it.
Your first line of code
Press Run and watch it print. Then edit the text inside the quotes and run again.
A program with several steps
Python reads a file top to bottom, running each statement in turn. Two prints, and a calculation in between.
How to read the output
print("Hello") prints Hello, not the quote marks — the quotes are part of the code, not the message.print(2 + 3) prints 5, because Python computes the addition before printing. Compare that with print("2 + 3"), which prints the text literally.print lines in the second editor and the output order flips with them.Hello, Python: A Practical Guide
Running code changes what you believe about it.
Quick Context
Python is an interpreted language: a program called the interpreter reads your file top to bottom and executes each statement immediately. There is no separate compile step, which is why the editor on this page can show you results the instant you press Run — the interpreter is running your code right in the browser.
The print function
print() is a function — a named chunk of work you call by writing its name and putting the input in parentheses. Whatever you hand it, it writes to the output. Try printing several things at once by separating them with commas: print("I am", 3, "steps ahead"). Notice Python inserts a space between the pieces for you.
Interactive Exploration Guide
- Edit the greeting. In the first editor, change the text inside the quotes to your own name and press Run.
- Break the quotes. Delete one of the quote marks and press Run. The error you get is Python complaining that it reached the end of the line while still reading a string — the single most common beginner error, and it is perfectly safe to make here.
- Numbers vs text. Replace
"Hello, Python!"with2 + 3(no quotes) and run again. Then runprint("2 + 3")and compare the two outputs. - Reorder the steps. In the second editor, move the last
print("Done!")to the top of the file and run. The output proves Python executed your lines in exactly the order you wrote them.
Key Takeaway
Everything a program does is the result of statements running top to bottom. print is your window into that — it turns invisible execution into text you can read. And the moment you can change code and see different output, you have moved from reading about programming to actually programming.