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!.
Tiny Practice: Your Greeting
Change the program so it displays a greeting with your name.
Starter template
print("Hello, world!")Line-by-line explanation
printdisplays text.- The text between quotes is the part to change.
Hint
- Keep
print(. - Keep straight quote marks around the message.
- Save before running.
Show Solution
print("Hello, Asha!")Line-by-line explanation
printasks Python to display something."Hello, Asha!"is one piece of text.- The output is
Hello, Asha!.