Python

Install Python on Windows 10

1. Overview

In this article, we will see how to install Python on Windows 10.

Python is one of the most widely used programming languages today. It first appeared in 1991. In this article, we take a look at how to install Python on a Windows machine.

2. What is Python?

Guido van Rossum created Python as a successor to the ABC programming language. The first version of Python got released in 1991. The most recent version is 3.9.6, as of writing this post.

Python is an interpreted language, meaning it has an interpreter instead of a compiler that converts code to machine language and executes it. This feature enables Python to be platform-independent. Python is also object-oriented, dynamically typed and garbage collected.

3. Installation steps

To get started with Python, we first have to install it on our systems. Generally, the Linux and Mac OS already have Python installed.

3.1 Verify Python version

To check if Python is already present on your machine

  • Open Command Prompt or cmd
  • Type the command:
 python -v

If Python is present, then the above command gives back the version number. If not, then the below message is displayed.

No Python found
No Python found

3.2 Install Python

 For Windows users, there are a couple of different ways to install Python

3.2.1 The Microsoft Store

  • Open the Microsoft Store.
  • In the window that opens, type “Python” in the search box.
  • Choose the latest version.
  • Hit the “Get” button to start the installation.
python windows 10 - microsoft store
Microsoft store

Alternatively, we can also open cmd and type python and, hit Enter. The command will open the same window as above. The Python that gets installed is not the complete package. It is enough if you are a beginner at Python. However, for the advanced concepts of Python, the complete package is preferred.

3.2.2 Download the latest package from the official Python site.

  • Go to the official Python site.
  • Click on the Download Python button.
  • The file that gets downloaded is python-3.9.6-amd64.exe
  • Double click on the file and follow the steps.
python windows 10 - installation steps
Python installation steps

The Python installed using the above steps is the complete Python package and is the recommended installation method. To verify that Python has installed correctly, repeat the steps for “Verify Python version.” You should be able to see output similar to this.

python windows 10 - python version
Correct Python version

We can also install Python by using distributions like Anaconda. Anaconda is a package management and deployment system and greatly simplifies adding other libraries to Python. To download Anaconda, download visit this site. The Anaconda documentation is available here.

4. Install Visual Studio Code (VS Code)

Python comes packaged with an IDE called IDLE. However, another IDE to use with Python for easier and faster development and testing is the Visual Studio Code or VS Code. To download VS Code, visit the official downloads page.

After Downloading VS Code, we also need to install the Python Extension pack in VS Code. We can do so by doing the following steps:

  • Open VS Code
  • Click the Extension icon.
  • Type Python or ms-python.python in the Search bar and select the first extension. Alternatively, we can also click on the Install button on this link, and it will do the same steps.
python windows 10 - Python Extension Pack
Python Extension Pack

5. Installing Git

Along with the Python interpreter and the IDE, we also need a versioning system. The most popular versioning system today is Git. VS Code comes packaged with Git. All we need to do to set up Git with VS Code is initialize a repository. All the details related to Git and how to get it set up are present here.

6. Python Basics

Python is an open-source, dynamic, high-level programming language. IT is easy to learn and easy to code. Python is dynamically typed, interpreted, and has an extensive library of in-built functions. The main difference between Python and other high-level languages is that in Python, the whitespace has significance. Python uses the whitespace to indicate blocks of code. For example, if we want a Python interpreter to print a line only if a condition is True, then we would write it as follows:

If num1 > num2:
     print(“The first number is greater than the second number.”)

The Python interpreter dynamically types variables, and hence we do not need to specify the data type when declaring variables. Python supports the following data types:

Type of dataData type
Test Typestr
Numeric Typesint, float, complex
Sequence Typeslist, tuple, range
Mapping Typesdict
Set Typesset, frozenset
Boolean Typesbool
Binary Typesbytes, bytearray,memoryview
Python data types

7. Running Python code in VS Code

To verify if Python is installed correctly in our system or not, we will write a simple program in VS Code using Python. We will four essential calculator functions: addition, subtraction, multiplication, and division. We reuse the same variable res for storing integer, float, and string values because Python dynamically types its variables.

first.py

def addition(number1, number2):
    result = number1 + number2
    return result

def subtraction(number1, number2):
    result = number1 + number2
    return result  

def multiplication(number1, number2):
    result = number1 * number2
    return result  

def division(number1, number2):
   if number2 !=0:
       result = number1/number2
       return result
   else:
        return "Division by zero is not possible." 


# Call addition function
res = addition(400, 300)
print("Addition results in ", res)

res = subtraction(400, 300)
print("Subtraction results in ", res)

res  = multiplication(4, 3)
print("Multiplication results in ", res)

res = division(4, 3)
print("Division results in ", res)

res = division(4, 0)
print("Division results in ", res)

To run this program in VS Code, open a terminal in VS Code and run the command

first.py

The output of the program is as follows:

Program Output
Program Output

8. Summary

In this article, we saw how to install Python on Windows 10. This is a highly popular, dynamically-typed, object-oriented language. In this article, we saw how to install and run Python in Windows. We also saw how to run a Python program in VS code. The Visual Studio Code documentation for Python is available here.

10. Download the Source Code

This was a tutorial on Python and how to install it on Windows.

Download
You can download the full source code of this example here: Install Python on Windows 10

Reshma Sathe

I am a recent Master of Computer Science degree graduate from the University Of Illinois at Urbana-Champaign.I have previously worked as a Software Engineer with projects ranging from production support to programming and software engineering.I am currently working on self-driven projects in Java, Python and Angular and also exploring other frontend and backend technologies.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button