First Python Program

In this tutorial, we will learn how to execute your first python program on python idle and other OS ; the same steps can be followed using Windows, Linux, and Mac OS.

First Python Program

Let us execute our first python program using python idle.

Step 1: Open idle.

Python interpreter Screen

Step 2: Click on File on the top menu and click on New File, or we can just use Keyboard shortcut  “Clt + N”

How to code in python?

As you see, we have opened the new file on idle now, we will write the python code below and save it by any name using the Clt + S keyboard shortcut, but it should end with the “.py” extension.

Step 3: Let’s begin to code with python by typing the below code.

print(“Hello Python”)

How to run a python program?

Let’s execute our first program by opening the Run menu from the top bar and click on “Run Module” or just the F5 key.

As you see, we have executed our first python program successfully.


interpreter Program

How to run a python program in windows?


You can use the Windows default command prompt to run the python program in windows. To open  CMD(Command prompt), you can type CMD on Run or search CMD in windows start.

Once you open the CMD, you can see a screen like below.

CMD view

You can type python command to check whether Python is installed or not, and if it is not installed, you can check our Install python page to install python on your respected operating system.


When you type python and press enter, you see the python interpreter, as shown below.

CMD interpreter

You can type the below code to execute the python program.

print(“Hello World”)

All python programs are stored in a ‘.py’ file, so when we develop any python program, it will be saved in ‘.py’ format.

To run a python program, you can use the python command followed by the file name with the python extension.


The output will be as below.

CMD Program

How to run a python program on Linux?

We can use the Linux terminal to run python programs in Linux/Ubuntu, which can be opened by pressing ‘Ctrl + Alt + T’ or just search terminal in the search bar of your operating system.

Linux Terminal

Like Windows, we can type python commands in the Linux terminal to check whether Python is installed or not; if python is installed on your PC, you will see the image below.

Linux Interpreter

To run a python program on Linux, you can simply use the python command followed by the program name, as shown below.

Linux Python Program