First Python Program

This tutorial will walk you through creating a simple Hello World! program in Python. You have several options to run the program. You can

  • use Python Interpreter to directly execute Python statements,
  • create a Python script file (*.py) and run it from the command prompt,
  • or use a Python editor like PyCharm.

Python Interpreter

If you want to test individual statements, Python Interpreter is your best choice. For instance, when you type 2+2 and press enter, the interpreter will print 4 on the console.

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20)
Type "help", "copyright", "credits" or "license" for more information.

>>> 2+2

To print “Hello World!” on the screen, you can use Python’s built-in function: print()

>>> print("Hello World!")
Hello World!

Script File

If you want to create more complex programs and save your work, you can use a Python script file. Script files allow you to save your code and execute the same code later when you need it.

To create a Python script file, open your text editor (Sublime Text, Atom, Notepad++,…), and type the following code. Save your file as Python script files have the extension .py.

print("Hello World!")

Once you have created a script file, you can execute it from the command line.

C:\Users\Your Name>python
Hello World!


Alternatively, you might prefer to use an IDE (Integrated Development Environment) for Python development. An IDE offers you a productive development environment.

PyCharm is one of the top IDEs for Python. PyCharm is a cross-platform development environment created by Jet Brains. It allows developing Python programs faster by tools like syntax highlighting, automatic code completion, builder and debugger. You can download the free Community edition of PyCharm from

Launch PyCharm IDE and click Create New Project.

PyCharm Create New Project

By default, the project location is set to C:\Users\User Name\PycharmProjects\untitled but you can change it. Make sure that Base interpreter shows the correct Python installation. Then click Create button.

If you cannot see Base interpreter, click on Project Interpreter to expand the settings.

PyCharm Create New Project

Once PyCharm finishes with creating the virtual environment, the editor opens with a screen like below.

PyCharm IDE First Project

To create your first Python program select New… from File menu, then select Python File. Type HelloWorld for Python file name.

Creating a Python File

Type the following code in file.

Python Hello World Source Code

Hello World Python program is ready to run. To run the program, select Run… from Run menu. The program runs and the output of print() function is displayed in Run window.

Running Python Code
Python Code Console Output