≡ Menu

Hello World In Python Tutorial

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

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 4 comments… add one }

  • Philippe Petrinko March 31, 2010, 12:55 pm

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

  • punktyras February 28, 2013, 3:55 pm

    language. ython is often

  • Hammad Khan March 26, 2013, 7:00 am

    You can also execute your scripts with this command line.

    python yourpythonfile.py

  • Matt T. April 27, 2014, 1:54 am

    You need to update this. Python 2.xx uses print ” “, while python 3.xx uses print(” “)

Leave a Comment