Learning Python with Raspberry Pi: Lesson #2

Instead of printing “Hello, world!” from the command line, let’s save it in a file. Then every time we call the file using python “Hello, world!” will print to your screen.

1. Open a terminal window.
2. Type vim hello.py. This creates a file called hello.py in the current directory and opens it for editing in the vi improved editor.
3. Type i to enter Insert mode.
4. Type print "Hello, world!"
5. Press the Esc button to exit Insert mode
6. Type :wq to save your changes and quit the editor
7. Type ls and you should see hello.py listed as one of the files
8. To run the program, type python hello.py
9. Press enter and you should see Hello, world! printed on your screen