Hello World Python – POFTUT

Hello World Python

We have talked about Python programming language previously. You can find them in Programming > Python section. Creating working environment for Python development and running our first python application is the first step to learning PYthon. In this tutorial we will look a Hello World python application about how can we create and run?

Create Source Code File

We will follow simple steps to create a source code or application file. In this way we will do not need any IDE or other third party applications. We will create our Hello Word application in a file named helloworld.py . We use py as extension to specify this . We will put following single line of code into helloworld.py file.

print("Hellow World")

Check Python

We will check whether python interpreter is installed. There is two main version of Python and its interpreter. We will prefer the never one which is Python3  . The older one is Python2. We will list the version of python like below.

$ python -V

If we specify only python command and -V option we see that default python interpreter is Python2. We can explicitly specify Python3 with python3 command like below.

$ python3 -V
Check Python
Check Python

Run Code With Python Interpreter

And we are here. We will run our source code file named helloworld.py against Python3 interpreter. We will issue them in command line like below.

$ python3 helloworld.py

Another way to run python file helloworld.py is making it directly executable in bash. We will make it by using chmod command like below.

$ chmod u+x helloworld.py

And we can run python file directly like below.

$ ./helloworld.py

LEARN MORE  What is chmod 777?

Leave a Comment