AnyCompiler

Your First Python Program

Every Python program you write will use print() constantly — it's how your code talks back to you. Let's break down exactly what it does, then run a real program.

The print() function

print() takes whatever you put inside the parentheses and displays it as output. Text (called a "string" in programming) needs to go inside quotes — either single (') or double (") work, as long as you're consistent within one string.

Comments

Anything after a # symbol on a line is a comment — Python ignores it completely. Comments exist purely for humans reading the code later (including future you), to explain why something is written the way it is.

Run it yourself

Here's a small program with a comment and two print() calls. This was actually executed to get the output shown below — try changing the text and running it yourself using the button under the example.

# This is a comment - Python ignores it
print("Hello, World!")
print("Welcome to Python.")
Output
Hello, World!
Welcome to Python.

Notice each print() call starts on its own new line in the output automatically — that's print()'s default behavior. You'll see how to change that later on.

Next: variables — how to actually store and reuse values instead of just printing fixed text.

Practice exercise

Add a comment above your code, then print "Learning Python one step at a time."