Home » Scripting and Automation » Python » Writing first python helloworld program

Writing first python helloworld program

If you have following installation / development environment setup steps from python page, to install python ( preferably python3 since its latest version ) . Its now time to write very first python program obviously helloworld python.

$ vim helloworld.py 
#!/usr/bin/env python

print ("Hello World")

Here, we created a file helloworld.py , notice the extension dot py i.e. “.py” which is used to mention, this is python program / script.

Inside this program, the first line “!/usr/bin/env python” is used to denote that this is a python code and program loader should consider “#!” as this is a script, and remaining “/usr/bin/env python” indicates it as python script.

The rest of the code .. print (“Hello World !”) .. is used print the simple string “Hello World!” , notice here you don’t need to add semicolon at the end of the line.

Now, this program can be executed from command line as,

$ python3 helloworld.py 

After execution, it will just print “Hello World” on console.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment