Print "Hello, World!"
Your very first Python program that prints "Hello, World!" to the screen.
BeginnerTopic: Basic Python Programs
What You'll Learn
- How to write and run your first Python program
- Using the built-in print() function
- Understanding basic string output
Python Print "Hello, World!" Program
This program helps you to learn the fundamental structure and syntax of Python programming.
# The classic first Python program
print("Hello, World!")Output
Hello, World!
Step-by-Step Breakdown
- 1Open a file named hello.py (or use a Python REPL).
- 2Write the line: print("Hello, World!")
- 3Run the file using: python hello.py
- 4Observe the output printed in the terminal.
Understanding Print "Hello, World!"
This is the traditional first program you write in any language. It helps you verify that Python is installed and working correctly on your system.
print() function
•
print() is a built-in Python function used to display output on the screen.•Whatever you pass inside the parentheses is printed.
•Text (string) values must be written inside quotes (single or double).
How it works
1.Python reads the line
print("Hello, World!").2.The string
"Hello, World!" is passed as an argument to print().3.Python sends this text to the standard output (your terminal or console).
This single-line program introduces:
•Python's simple and clean syntax
•How to run a script
•How to display information to the user
Let us now understand every line and the components of the above program.
Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.