Of course! The "Hello, World!" program is the traditional first program you write when learning a new language. Its purpose is to simply display the text "Hello, World!" on the screen.

In Python, it's one of the simplest and most elegant examples possible.
The Code
Here is the complete "Hello, World!" program in Python:
print("Hello, World!")
How to Run It
You have two easy ways to run this code.
Method 1: Using the Python Interactive Interpreter (Great for quick tests)
-
Open your terminal or command prompt.
(图片来源网络,侵删)- On Windows: Search for "Command Prompt" or "PowerShell".
- On macOS or Linux: Open the "Terminal" application.
-
Type
pythonorpython3and press Enter. You should see a>>>prompt.$ python3 Python 3.10.4 (main, Jun 29 2025, 12:14:53) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
-
Type the
printstatement directly into the interpreter and press Enter.>>> print("Hello, World!") Hello, World! -
To exit the interpreter, type
exit()or pressCtrl+D.
Method 2: Using a Script File (The standard way)
This is the most common method for writing and running programs.

-
Create a file:
- Open any plain text editor (like Notepad, VS Code, Sublime Text, etc.).
- Save the file with a
.pyextension. For example,hello.py.
-
Write the code:
- Type the
printstatement into the file and save it.# hello.py print("Hello, World!")
- Type the
-
Run the script from your terminal:
- Navigate to the directory where you saved your file using the
cdcommand. For example:cd Desktop. - Run the file using the
pythoncommand:$ python3 hello.py Hello, World!
- Navigate to the directory where you saved your file using the
Code Breakdown
Let's break down that single line of code:
print("Hello, World!")
print()is a function in Python. A function is a reusable block of code that performs a specific action. Theprint()function's job is to display output to the console."Hello, World!"is a string. A string is simply a sequence of text. In Python, strings are enclosed in either double quotes () or single quotes ().- The parentheses are used to call the function. Anything you put inside the parentheses is called an argument, which is the input you are giving to the function. Here, you are giving the
print()function the string"Hello, World!"as input.
So, in plain English, that line of code reads: "Call the print function with the argument Hello, World!."
Welcome to the world of Python! This is the first step in a very exciting journey.
