GPIO and Python (1/9) - Hello World

GPIO and Python (1/9) - Hello World

Run your first python program “hello world”

Things you will need:

Raspberry Pi + SD Card
Keyboard + Mouse
Monitor + HDMI Cable
Power Supply


Latest version of Rasbian installed on your SD Card
Raspberry Pi setup with a keyboard, mouse and monitor


1. Start by opening a Terminal, by click the icon in the taskbar

2. Start by creating a new directory, this is where we are going to store all our scripts for this series of tutorials, make a directory called gpio_python_code:

 mkdir gpio_python_code

3. We can use the command ls -l to view the contents of the current directory:

 ls -l

You should be able to see the directory you created

4. Now we need to change our current directory to the newly created gpio_python_code directory:

 cd gpio_python_code

5. Using the touch command, we can create an empty file. This will be where we are going to code our Hello World script.


6. Once we have created our empty file, we can use the command nano, to open it in a text editor.


7. Now enter the following code:


#Print Hello world

print "Hello World!"

8. Press ctrl+X to exit, you will be prompted to save the file, simply press Y, and then be you will be prompted to give the file a name.
It will automatically use its current name, so just hit enter to accept.

9. To execute your script, simply enter the following command:

 sudo python

Leave a comment

All comments are moderated before being published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.