Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Python 3, the classic Hello World program is one line: print("Hello, World!"). Type it at Python’s interactive prompt to see the result immediately, or save it in hello.py and run the file from a terminal.

What is the Python 3 Hello World program?

Use this line:

print("Hello, World!")

print() is a built-in function in Python 3. The text to display goes inside its parentheses and quotation marks. When the program runs, it prints Hello, World! to the screen.

Python 2 examples often show print "Hello, World!" without parentheses because Python 2 treated print as a statement. For current learning, use Python 3 syntax. The official Python tutorial introduces Python 3 and describes the language as “easy to learn” and powerful.

How to run the line in Python’s interactive prompt

The interactive interpreter lets you enter Python code and see the result without first saving a file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Install Python 3 using the official Python distribution or the installation instructions for your platform.
  2. Open Terminal on macOS or Linux, or Command Prompt on Windows.
  3. Start Python by entering python3 on macOS or Linux, or python on Windows, then press Enter. You should see a Python 3.x version and the >>> prompt. Google’s Python setup guide demonstrates these command patterns.
  4. At the >>> prompt, type print("Hello, World!") and press Enter.

The interpreter displays:

Hello, World!

The >>> prompt is where you enter Python statements. To leave the interpreter, enter exit() and press Enter; on some platforms, you can also use Ctrl-D on macOS or Linux, or Ctrl-Z followed by Enter on Windows.

How to save and run a Python file

A saved script is useful when you want to run the program again or build on it.

  1. Open a plain-text editor and enter print("Hello, World!").
  2. Save the file as hello.py. Make sure the editor does not add an extra extension such as .txt.
  3. In the terminal or Command Prompt, change to the folder containing the file.
  4. Run the script with the command for your platform:
  • macOS or Linux: python3 hello.py
  • Windows: python hello.py

The expected output is Hello, World!. If the terminal says that the command is not recognized or not found, Python may not be installed or its command may not be available on your system’s PATH. Check your installation and platform setup instructions.

What to check if it does not work

  • Command not found or not recognized: Install Python 3, then reopen the terminal and try the platform command again. Some computers may have an outdated Python 2 installation, so check that the interpreter you start reports Python 3.x.
  • The file cannot be opened: Confirm that the terminal is in the folder containing hello.py, and check that the filename is not actually hello.py.txt.
  • Syntax error near print: Use Python 3 and the parentheses in print("Hello, World!"). An example without parentheses may be written for Python 2.
  • The prompt shows >>> but the file command fails: You are likely inside the interactive interpreter. Enter exit() first, then run the script command in the system terminal.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to learn after Hello World

This example confirms that you can run Python code, but it does not yet use variables or make decisions. A natural next sequence is the interpreter, variables and text, control flow, functions, and data structures. Python’s official tutorial is aimed at programmers who are new to Python but assumes some general programming familiarity. For a gentler introduction, the Python Beginner’s Guide provides installation context, while LearnPython.org offers beginner explanations and interactive exercises.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.