Python “hello, world!” (in a file)

This tutorial recaps the Python “hello, world!” of the previous the tutorial. The difference is that here you’ll save the code you write to disk.

Writing the file

Change to whatever directory you’d like and then use your text editor to create a new file called hello_world.py.

Type the following line of Python code into hello_world.py:

print('hello, world!')

Save hello_world.py when you’re done.

Interpreting the file

Open the terminal and call Python on hello_world.py:

$ python hello_world.py
hello, world!

Python reads hello_world.py as input and outputs hello, world! to the terminal.

Repeating the process

Working with Python files means doing these things:

1. write a file
2. interpret the file
3. repeat 1 - 2

Experience will make this edit-interpret loop familiar. And no matter how complicated the projects you develop this way of working with Python files will stay the same.