Hello World In Python Tutorial

by on March 18, 2008 · 3 comments· last updated at November 15, 2012

How do I write my first program in python? How do I print "hello world" message in Python?

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsPython

Python is easy to use, general-purpose high-level programming language. ython is often used as a scripting language and for writing tasks such as:

=> Sys admin programming

=> Web projects

=> GUI projects etc

Task: Write "Hello world" program in python

Use a text editor such as vi, gedit or any other text editor. Create a program file called hello.py:
$ vi hello.py
Now type the following program:

#!/usr/bin/python
# My first python program
print "Hello, World!\n"
 

Save and close the file. Type the following command to set permission:
$ chmod +x hello.py
To run a program, enter:
$ ./hello.py



You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 3 comments… read them below or add one }

1 Philippe Petrinko March 31, 2010 at 12:55 pm

Yeah, right, but it misses your usual and useful “Further Readings” chapter… ;-)

Reply

2 punktyras February 28, 2013 at 3:55 pm

language. ython is often

Reply

3 Hammad Khan March 26, 2013 at 7:00 am

You can also execute your scripts with this command line.

python yourpythonfile.py

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: