≡ Menu

Hello World In Python Tutorial

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

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:

# 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

Share this tutorial on:
{ 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(” “)

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , ,