9303753286127016 Python Hello World Program (Step by Step using Pycharm + Visual Studio Code)

Python Hello World Program (Step by Step using Pycharm + Visual Studio Code)

Previous

Python Hello World Program (Step by Step using Pycharm + Visual Studio Code)

In this python tutorial, we will build our first traditional Python Hello world program using Pycharm and Visual studio code. If you want to learn Python as a beginner, then let us create a hello world program in Python using vscode and pycharm.

Any of the editors (Pycharm or Visual Studio Code), you can use for coding in Python.

This is a step by step tutorial to create your first hello world program in Python using Pycharm and Visual Studio Code.

Python Hello World program using Python 3.8 and Pycharm 2022

I have installed python version 3.8.2 and Pycharm version 2022. as the code editor which we will use to build the first program.

Now our python is installed and code editor (Pycharm) is also installed in my machine. Both are with the latest version as of April 2022. 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
pycharm hello world

Step-3:

Now in this step first give a meaningful name to the project. I gave the name “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?
Python Hello World Program

Step-4:

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

python hello world pycharm
python hello world pycharm

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 python pycharm
hello world python pycharm

Step-6:

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

hello world program in python using pycharm
Python Hello World Program

Step-7:

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

Create a hello world program using Pycharm
hello world program in python using pycharm

Step-8:

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

hello world in pycharm
hello world in pycharm

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
print hello world in pycharm

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
Python Hello World Program

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
python 3.8 hello world

Step-12:

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

Print("Hello world!!")
python hello world program
python hello world program

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/PyCharmCE20221/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” which means Run “Filename”.

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

pycharm hello world program
pycharm hello world program

Now let’s run the program.

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

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
hello world pycharm

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:

cd C:\Users\MAYANK\AppData\Roaming\JetBrains\PyCharmCE2022.1\scratches

Note: C:\Users\MAYANK\AppData\Roaming\JetBrains\PyCharmCE2022.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.


Run your Python file from the command prompt
Run your Python file from the command prompt

This is how we can create your first hello world program using Python in Pycharm.

Create a hello world program in Python using Visual Studio Code

Now, let us see, how to create a hello world program in python, and also, we will see how to download and install visual studio code in windows 10.

What is Visual Studio Code?Microsoft provides a Visual Studio Code the free and open-source code editor. It is fast and straightforward. Visual Studio Code supports all three operating systems like Windows, Linux, and macOS.

It has a lot of built-in features like GitHub, debugging and embedded Git control, syntax highlighting, snippets, and intelligent code completion. Also, you can add extensions to create a Python development environment as per your need.

VS Code is lightweight and it has many powerful features. This is the reason why it becoming popular among Python developers. Visual studio code is a code editor that you can use for python development. This is not only mean for python, It supports other languages also.

Download and Install Visual Studio Code in Windows 10

Let’s see how to download and install free visual studio code (VS Code).

Step-1First download visual studio code. Based on the operating system, you can download VS Code.

visual studio code download and installation
visual studio code

Step-2

  • After downloading, Open the VS Code and then accept the agreement and click on Next.
  • Once you will click on Next, a default location will appear. If you don’t want to change the default location then click on Next.
visual studio code download
download and install vs code

Step-3Now click on “create a desktop icon” so that it can be accessed from desktop and then click on Next.

How to download visual studio code
visual studio code

Step-4

After that, click on the Install button. It will start installing the VS Code.

visual studio code download 64-bit windows 10
visual studio code for python

Step-5

Finally, installation completes, and by default the Launch Visual Studio Code will appear with check mark. Click on the Finish button, and the visual studio code will get open.

download visual studio code
visual studio code for python

Step-6

Now you can see Visual Studio Code has been started on windows 10.

How to download visual studio code
Python Extension for Visual Studio Code

Install Python Extension for Visual Studio Code

To install the extension, open up the extension, menu which is present on the left side, and write on the search space “Python”.

Then select the first one that pops up, You can click Install for the respective extension.

install python extension vs code
Python Extension for Visual Studio Code

Create hello world program in python using Visual Studio Code

Now, we will see how to create hello world program in python in vs code.

Open visual studio code. Then File -> New File.

Then in the file write the below code:

msg = "Hello World"
print(msg)

Then Save the file Ctrl+S and then give a file name with .py extension and save type as Python.

python hello world program
visual studio code python hello world

The file will looks like below:

python hello world program using vs code
hello world python visual studio code

To Run the code, Right-click anywhere in the editor window and select Run Python File in Terminal.

create hello world program in python
vscode python hello world

Output:

The output you can see in the Terminal like below:

how to create hello world program in python
python hello world visual studio code

You can also, Run the code manually using the command line by simply writing python and Path of the file in the terminal.

create a basic hello world program in python
vs code python hello world

You can see below, I have copied the Path of the File after writing python.

python E:\project-python\HelloWorld.py
create hello world program in python
create hello world program in python

Now, If you enter then you will see the Output.

hello world python program
python hello world vscode

We can follow the above steps to create hello world program in python using visual studio code. And how to download and install Visual Studio Code in windows 10, and also we have seen how to install Python Extensions in vs code.

Balkishan Agrawal

At the helm of GMS Learning is Principal Balkishan Agrawal, a dedicated and experienced educationist. Under his able guidance, our school has flourished academically and has achieved remarkable milestones in various fields. Principal Agrawal’s vision for the school is centered on providing a nurturing environment where every student can thrive, learn, and grow.

Post a Comment

Previous Post Next Post