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.

Related :   How to concatenate strings in Python ?

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

$ python3 helloworld.py 

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


lynxbee_ezoic

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


Leave a Comment

Android Android Applications Android Build system Android Commands Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded