Javatpoint Logo
Javatpoint Logo

First Python Program

In this Section, we will discuss the basic syntax of Python, we will run a simple program to print Hello World on the console.

Python provides us the two ways to run a program:

  • Using Interactive interpreter prompt
  • Using a script file

Let's discuss each one of them in detail.

Interactive interpreter prompt

Python provides us the feature to execute the Python statement one by one at the interactive prompt. It is preferable in the case where we are concerned about the output of each line of our Python program.

To open the interactive mode, open the terminal (or command prompt) and type python (python3 in case if you have Python2 and Python3 both installed on your system).

It will open the following prompt where we can execute the Python statement and check their impact on the console.

First Python Program First Python Program

Here, we get the message "Hello World !" printed on the console.

Using a script file

Interpreter prompt is good to run the individual statements of the code. However, we cannot write the code every-time on the terminal.

We need to write our code into a file which can be executed later. For this purpose, open an editor like notepad, create a file named (Python used .py extension) and write the following code in it.

To run this file named as, we need to run the following command on the terminal.

$ python3

First Python Program

Hence, we get our output as the message Hello World ! is printed on the console.

Get Started with PyCharm

In our first program, we have used gedit on our CentOS as an editor. On Windows, we have an alternative like notepad or notepad++ to edit the code. However, these editors are not used as IDE for python since they are unable to show the syntax related suggestions.

JetBrains provides the most popular and a widely used cross-platform IDE PyCharm to run the python programs.

PyCharm installation

As we have already stated, PyCharm is a cross-platform IDE, and hence it can be installed on a variety of the operating systems. In this section of the tutorial, we will cover the installation process of PyCharm on Windows, MacOS, CentOS, and Ubuntu.


Installing PyCharm on Windows is very simple. To install PyCharm on Windows operating system, visit the link to download the executable installer. Double click the installer (.exe) file and install PyCharm by clicking next at each step.

To create a first program to Pycharm follows the following step.

Step - 1. Open Pycharm editor. Click on "Create New Project" option to create new project.

First Python Program

Step - 2. Select a location to save the project.

  1. We can save the newly created project at desired memory location or can keep file location as it is but atleast change the project default name untitled to "FirstProject" or something meaningful.
  2. Pycharm automatically found the installed Python interpreter.
  3. After change the name click on the "Create" Button.
First Python Program

Step - 3. Click on "File" menu and select "New". By clicking "New" option it will show various file formats. Select the "Python File".

First Python Program

Step - 4. Now type the name of the Python file and click on "OK". We have written the "FirstProgram".

First Python Program

Step - 5. Now type the first program - print("Hello World") then click on the "Run" menu to run program.

First Python Program

Step - 6. The output will appear at the bottom of the screen.

First Python Program
Next TopicPython Variables

Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA