Create and Run Python Program using PyCharm

Create and Run Python Program Using PyCharm

A Python-specific Integrated Development Environment (IDE) called PyCharm offers a large range of crucial features for Python developers.

Python programming can be done using the integrated development environment PyCharm. In addition to supporting Django web development, it offers code analysis, a graphical debugger, an integrated unit tester, integration with version control systems, and more. The JetBrains firm in the Czech Republic creates PyCharm.

In this post we will discuss how to create and run a python program using PyCharm. For this we need to follow below simple steps:

  1. Install Python
  2. Install PyCharm
  3. Open PyCharm on your computer. It will show the interface like below image.
Open PyCharm IDE for Python
Open PyCharm IDE for Python

Go to top left menu. Select File–>New Project

Create a new Project in PyCharm Python IDE
Create a new Project in PyCharm Python IDE

Under the new project templates, select “Pure Python”, then select the path or location where you want to keep this project files. Add the name of the project( here MyProject) at the end of the location or path.

Select the base interpreter, which is python exe location on your computer.

Then click create.

Select the path or location of project in pycharm
Select the path or location of project in pycharm

Then a popup may appear as below, preferably select “This Window”.

Open the PyCharm Project in the Same Window
Open the PyCharm Project in the Same Window

The new project named “MyProject” will be created and displayed in the left window. Note that it has a virtual environment created named venv.

PyCharm IDE New Project Creation
PyCharm IDE New Project Creation

Right click on the MyProject–> New–>Python File to add a new python file to your project.

Add a New Python File to a PyCharm Project
Add a New Python File to a PyCharm Project

A pop up will appear for naming the upcoming python file. Name it, for example “HelloWorld” and hit enter.

Name a New Python File to a PyCharm Project
Name a New Python File to a PyCharm Project

The HelloWorld.py file is created in the my project folder. Write a small one line program in this file. For example print(“Hello World”).

Write a Hello World Python Program in PyTorch IDE
Write a Hello World Python Program in PyTorch IDE

Go to the top Run menu. Click on it and select Run.

Run a Hello World Python Program in PyTorch IDE
Run a Hello World Python Program in PyTorch IDE

The python program is run and the output “Hello World” is displayed in the run tab at the bottom as shown in the image below.

Congratulations!! you just ran your first python program in PyCharm.

Learn more about PyCharm features.

Leave a Reply

%d bloggers like this: