/  Technology   /  How to code in Python using Visual studio
How to code in Python using Visual studio

How to code in Python using Visual studio

Python is simple, easy to learn, interpreted, object-oriented , high-level programming language.

The visual studio as IDE for python programming:

IDE provides an interface and convenient view for the development process. It helps to write, built, and debug programs.

Visual Studio is developed by Microsoft. Visual studio can be used for many programming languages such as  Java, Javascript, Node.js, C++, etc in this case we can use it for python by simply downloading and installing the corresponding plugin to adapt to the environment. Python has strong support in visual studio.

Visual studio has features such as integration of powerful code auto compilation engine also known as IntelliSense, debugging console, and terminal to launch server command. It has extension-based architecture so it can be extended by adding successive component as needed this make it outstanding.

Prerequisites:

  • You must install Python on your machine.
  • You must set up the local development environment

 

Step 1:  Downloading and installing a visual studio

 we have to first download the visual studio and install it on our personal computer. To download the visual studio click on this website given.

Official website: https://code.visualstudio.com

 

How to code in Python using Visual studio

 

After completion of the download, install it in your pc.

Step 2: Installing the python extension for visual studio

Make sure that you have download the python and set up the environment as in prerequisite.

In this, we are going to install the python extension in the visual studio. To install the extension, open the extension menu on the left side and search python in the search bar.

How to code in Python using Visual studio

It will search python extension for detail about the extension you can view the detail and click on the install tab to install.

By this, we can use the visual studio code for python programming. We can also install the linter to get the error and warning in our code .we can further customize the linting rule to fit our need.

Step 3: Running python code in visual studio code

Open the folder in which we have to save our python code. Create a file in an opened folder with .py  extension, (.py) extension means it is python file.

How to code in Python using Visual studio

For output terminal open the terminal in the above bar select the view and then select terminal or we can use the shortcut for terminal ctrl+`.Now we are ready to write our first python code in Visual studio.

For example:

Python code:

Print(“welcome to python programming”)

To run the python file in the terminal right clicked and select “run python file in terminal”.

How to code in Python using Visual studio

Output:

The output of the above code written is

How to code in Python using Visual studio

In this way, we can write, compile, and run our python code using visual studio code.

Features:

  1. Highlighting syntax:

The syntax of the code is highlighted this provides an efficient way for coding.

print("welcome to python programming")
  1. Autocompletion:

It supports autocompletion which predicts the rest of the code that we are writing.

How to code in Python using Visual studio

Here, we will notice that some information pops up. If we want to use that function then we have to press ENTER or TAB.

  1. Intellisense:

It also supports IntelliSense,through which we can edit out code with auto compilation, code navigation, and syntax checking.

 

  1. Shortcut for running python files

It also provides shortcuts for running python files and other useful miscellaneous shortcuts.

 

 

 

 

 

 

 

 

Leave a comment