Open a plain-text code editor such as Visual Studio Code, Windows Notepad, or TextEdit in plain-text mode. Create a new file and save it as hello.py inside Documents.
Type exactly one line into the file:
print("Hello, world!")Line-by-line explanation
printis a Python instruction that displays a value.(opens the place where information is given toprint."begins the text.Hello, world!is the text.- The next
"ends the text. )closes the instruction.
Save the file. Open a terminal, move into Documents, and run it on Windows:
python hello.pyLine-by-line explanation
pythonstarts the Python interpreter.hello.pytells Python which file to run.- The output should be
Hello, world!.
On macOS or Linux, use:
python3 hello.pyLine-by-line explanation
python3starts Python 3.hello.pyis the file to run.- The output should be
Hello, world!.