element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
STEM Academy
  • Learn
  • Learning Center
  • STEM Academy
  • More
  • Cancel
STEM Academy
Blog Raspberry Pi - HelloWorld
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STEM Academy to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ntewinkel
  • Date Created: 20 Nov 2014 4:56 AM Date Created
  • Views 1535 views
  • Likes 5 likes
  • Comments 7 comments
  • python
  • helloworld
  • raspberrypi
  • stem space
Related
Recommended

Raspberry Pi - HelloWorld

ntewinkel
ntewinkel
20 Nov 2014

Hi All,

 

In this blog post I go through the very first basic steps of programming a Raspberry Pi using Python, to run the familiar starting program "Hello World" image

 

Note that this is geared for people who are complete beginners with Raspberry Pi.

 

My first thought was that this must have been done a zillion times before, but when I started looking I couldn't find anything that summed it up in easy steps, and I found myself having to dig a little just to get the first steps figured out. Not too difficult, but a bit annoying. So I thought I may as well track what I'm doing and make this blog post, in the hopes that it might make someone else's life a bit easier.

 

First of all, I'm assuming that your Raspberry Pi is already set up, and that you are using the Graphical User Interface. I'm using Raspbian here, and all my steps will be based on that. I'm also using the version of Raspbian that came on a NOOBS SD card, circa October 2014. So if your version is older it may not have all the tools installed in the same way. In that case, please refer to the many other resources out there that can do a much better job than I of explaining how to update and/or install the software.

If all else fails, it might be easiest just to get a new SD card and install the latest version of Raspbian on it.

 

I am doing this on a Raspberry Pi Model B+, but everything should work the same way on other models.

 

The tool we will use is "IDLE 3", which is a handy little Python editor. It comes pre-installed with Raspbian.

 

The first step is to just double-click the IDLE 3 icon to open the "shell" - basically a line by line Python interpreter.

Now you can try your very first line of Python: at the >>> prompt, type this line:

print("Hello World!")

then press the enter key. The shell should respond by printing "Hello World!" on the next line and then giving you a new >>> prompt.

 

The shell provides a nice and easy way to try single line Python commands, but most programs require more than one line. To accomplish this, you need to either open a file, or create a new file.

Let's create a new file: from the file menu of the Python Shell window, choose "New Window".

A new window titled "Untitled" will pop up on your desktop, and it'll be a blank slate. We'll just ignore the obvious self-contradiction of the title of the window. But this is where you can now start typing in your program.

 

Keeping with the super-easy theme, let's also make it say "Hello World!", by typing the same line as before, but this time type it into the Untitled window.

You'll notice that it won't automatically try to run it. That's the point - it gives you time to type out a more complex program before it tries to run it.

 

To run it, we'll need to save the file first. The usual ctrl-S or File-Save will do the trick. Put it somewhere where you'll be able to find it back later, of course. I prefer to put it under "Documents", as I'm not using this Raspberry Pi computer for anything else.

 

Now from the file menu, select Run and Run Module to run your new Hello World program.

 

You'll notice that it switches the window selection to the Python Shell, and then prints a long line that says "RESTART", shows a prompt, then shows your "Hello World!" line, and then another prompt.

 

image

 

That's it! That's all there's too it.

 

Now the next time you open IDLE 3, you can simply use "File-Open..." to open the existing helloworld.py file and run it again.

 

I hope that helps out. My next blog post will go on to show how to blink an LED - the basic microprocessor version of "Hello World" image

 

Edit: This has been tested and works on both the RPi model B+ and the RPi 2 model B.

 

Cheers,

-Nico

  • Sign in to reply

Top Comments

  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago in reply to dragonstyne +2
    As Mike correctly pointed out, C is compiled, not interpreted (So Faster) and uses GCC as the compiler, I will dig up some of the code that I and My Son have done in the pursuit of him learning to program…
  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago +1
    Nicely done there, I have only programmed the PI in "C" so far so its good to see how the other side lives Peter
  • ntewinkel
    ntewinkel over 10 years ago in reply to Robert Peter Oakes +1
    Thanks Peter! I figured I should try Python, to keep with the whole "Pi" theme (Plus it seemed like it might be less effort overall)
Parents
  • mconners
    mconners over 10 years ago

    Nice job, Nico.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • mconners
    mconners over 10 years ago

    Nice job, Nico.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube