Hello World In Python Tutorial

by on March 18, 2008 · 3 comments· LAST UPDATED November 15, 2012

in , ,

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
Estimated completion timeN/A

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 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

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

Previous Faq:

Next Faq: