Python Scripting (7 Blogs) Become a Certified Professional
AWS Global Infrastructure

Programming & Frameworks

Topics Covered
  • C Programming and Data Structures (16 Blogs)
  • Comprehensive Java Course (5 Blogs)
  • Java/J2EE and SOA (346 Blogs)
  • Spring Framework (8 Blogs)
SEE MORE

Python 101 : Hello World Program

Last updated on Apr 28,2020 11.9K Views

6 / 6 Blog from Python Installation

Python: Hello World

One of the primary lessons for any beginner in Programming is the ‘Hello World’ program. Here, we will see how the ‘Hello World’ Program is executed and also get you started with what Python is all about. To master Python you need to work with real-world case studies & this blog is a stepping stone towards it.

Python is a general purpose interpreted, high-level and object-oriented programming language. This language is easy to learn, read and maintain. It is also portable and is often called a beginners’ language. It supports almost every operating system and is quite a simple language.  Python has a very straightforward syntax, while encouraging programmers to program without boilerplate (prepared) code.

The simplest directive in Python is the “print” directive – it simply prints out a line (and also includes a newline, unlike in C). There are two major Python versions, Python 2 and Python 3. Python 2 and 3 are quite different. This tutorial uses Python 2, because it is more widely used and supported. However, Python 3 is more semantically correct, and supports newer features.

How do we go about writing a simple Hello World Program in the Python world? Let us take a look:

Step 1: Download Python

The official Site for Python downloads: https://www.python.org/download
Python 101 - Hello World Program

Download Python for your Operating system.
Python 101 - Hello World Program

Step 2: Install Python 

Python 101 - Hello World Program
Python 101 - Hello World Program
Python 101 - Hello World Program

Step 3: Go To Python Install directory (Cmd)

Default Location for Python 3.4 is: C:/Python34
Python 101 - Hello World Program

Alternatively you can open the Python shell from the Python Install Directory:
Python 101 - Hello World Program

Step 4: Hello World Program

Now, the syntax of the actual program depends on the version of the python program being used:

On the command Line, write the Python code:  print (“Hello World”) and push Enter. Python will automatically echo the Output to screen.
Python 101 - Hello World Program

Alternatively, if one wants to execute Python code post, saving the code in a file here is what one can do:

Start up your favorite editor and save the following into a file:

 print "Hello, World!"

To execute this program, save it with a suffix of ‘.py’ (e.g., HelloWorld.py) and type ‘python’ and the filename in a shell-like this:

 > python HelloWorld.py

The output is predictable:

Hello, World!
Python 101 - Hello World Program

If you prefer to execute it by its name, instead of as argument to the Python interpreter, put a “bang” line at the top. Include the following on the first line of the program, substituting the absolute path to the Python interpreter for /’path/to/python’:

#!/path/to/python

Be sure to change the permission on the file to allow execution, if necessary for your operating system.

We hope this helps you give a kick start to Learning Python!

Got a question for us? Mention them in the comments section and we will get back to you.

Related Posts:

Python for Big Data Analytics

Strings in Python

Get started with your Python Course!

Comments
1 Comment
  • Which OS is best to use Python development? Please let me know the advantages and Dis-advantages of using different OS.

Join the discussion

Browse Categories

webinar REGISTER FOR FREE WEBINAR
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.

image not found!
image not found!

Python 101 : Hello World Program

edureka.co