Python Hello World Program (using Pycharm)

By: On:

In this python tutorial, we will build our first traditional Python Hello world program. I have installed python version 3.8.2 and Pycharm version 2020.1 as the code editor which we will use to build the first program.

So in my last blog we discussed how can we install python3 in different operating system and we saw the installation of different code editors and IDEs used to write the python code.

If you didn’t go through that you can see once Python download and Installation steps (Windows 10/Unix/Mac/Ubuntu/CentOS ).


Python Hello World program using python 3.8 and Pycharm 2020

Now our python is installed and code editor (Pycharm) is also installed in my machine. Both are with the latest version as of April 2020. Let’s start our first program.

Step-1:

Open the Pycharm code editor

Python Program to Print Hello World
Python Hello World program

Step-2:


Now next is click on “Create New Project” button.

Python3 Program to Print Hello World

Step-3:

Now in this step first give a meaning full name to the project. I gave the name as “Helloworld”. You can change your preferred location also. Base Interpreter will be populated automatically. Now please click on the create button.

How do you write a first program in Python?

Step-4:

Now the below popup will appear, you can just close the tip of the day pop up.

Say "HelloWorld!" With Python

Step-5:

Now the below popup shows some helpful information. See once. One more important thing among these is you can drag and drop a file there so that it will open.

Hello, World!

Step-6:

In this step Click on File –> New Scratch file.

Hello World: Create your First Python Program

Step-7:

Now choose “Python” from the New scratch file pop up.

Create a hello world program using Pycharm

Step-8:

Now see below one python file with name scratch.py got created.

Python script to print Hello World on screen

Step-9:

Now give a meaning full name to the file. So we need to rename this file. Right-click on the Scratch.py and select the Rename file.

Python3 script to print Hello World on screen

Step-10:

Below Rename pop up will appear, Give a Proper name. In this case I gave the name as Helloworld.py. Then click on the Refactor button.

How to create a hello world program using python 3.8 version

Step-11:

Now, see the file name has been renamed to “Helloworld.py”. So now our empty python file is ready.

How to create a python hello world program

Step-12:

Now write the below code in the Helloworld.py file and then Click on run –> Run option. You can also use keyboard shortcut Alt+Shift+F10 to run the file.

Print("Hello world!!")
print('Hello World')

Step-13:

Oops, While executing the above code,It throws me the below error

Traceback (most recent call last):
  File "C:/Users/Bijay/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/Helloworld.py", line 1, in <module>
    Print('Hello world!!')
NameError: name 'Print' is not defined

Any guess why the above error. This is because We entered the print as Print(caps P). The correct one should be print().

Note: Python is case sensitive.

So the correct line of code is as below.

print(Hello world!!)

Now enter the above code and run the file. Let’s see what’s happening. Now if you will notice here the run option is Run”HelloWorld” that means Run””Filename.

Now when I changed the Print(caps P) to print(). If you will see below the auto-suggestion box showing print function displayed.

print('Hello World')

Now let’s run the program.

Create a hello world Program using python 3.8 and Pycharm 2020.1.

Step-14:

Congratulations, Yes I got the expected output with out any error this time. See below.

How To Write Your First Python 3 Program

Run your Python file from the command prompt

There is one more approach to run your python file form your command prompt if you don’t have Pycharm installed in your machine.

Step-1:

Open your command prompt and go to the path where your python file is present. To do so use the below command and press enter.

cd C:\Users\Bijay\AppData\Roaming\JetBrains\PyCharmCE2020.1\scratches

Note: C:\Users\Bijay\AppData\Roaming\JetBrains\PyCharmCE2020.1\scratches is the path for me where my HelloWorld.py file presents. So I need to go to that path and execute the code.

Step-2:

Now put file name i.e Helloworld.py and press enter. See below we got the expected output.

Create hello world file using pycharm 2020

You may like following below Python Tutorials:

Conclusion

Here in this tutorial, We have completed developing our first hello world program using python version 3.8 and Pycharm version 2020.1 as a code editor.


Python is the best!!!!!

This python tutorial explains the below points:

  • How to create a Python Hello World program using python 3.8 with Pycharm 2020 code editor?
  • Run your Python file from the command prompt.

Leave a Comment