1. Computing
Send to a Friend via Email

"Hello, World!": A Quick Tutorial on Python


1 of 6

Introducing "Hello, World!"

The simplest program in Python consists of a line that tells the computer a command. Traditionally, the first program of every programmer in every new language prints "Hello, World!". Start up your favorite editor and save the following into a file:

 print "Hello, World!" 

To execute this program, save it with a suffix of '.py' (e.g., HelloWorld.py) and type 'python' and the filename in a shell like this:

 > python HelloWorld.py 
The output is predictable:
Hello, World!

If you prefer to execute it by its name, instead of as an argument to the Python interpreter, put a "bang" line at the top. Include the following on the first line of the program, substituting the absolute path to the Python interpreter for /'path/to/python':

Be sure to give change the permission on the file to allows execution, if necessary for your operating system.

Now, let's take this program and embellish it a bit.

  1. About.com
  2. Computing
  3. Python
  4. Beginning Python
  5. Python "Hello World" Tutorial - "Hello, World!": A Quick Tutorial on Python

©2014 About.com. All rights reserved.