How to find the square root of a number with Python

Being passionate about maths, I have started to explore some basic Python modules which can help to put in practice mathematical theory. During my years in high school, I had to deal a lot with exercises that require the square root of a number. For those of you who don’t know, in mathematics, the square root of a number is y such that y*y equals that number.

For example, the square root of number 16 is number 4; 4 times 4 equals to 16. Being rich in features, the Python computer programming language offers a module which can be easily utilized to automatically find the root square of a number.

What's the one thing every developer wants? More screens! Enhance your coding experience with an external monitor to increase screen real estate.

Before going any further with this article, make sure to launch a new Python interactive console in your own operating system. Once you have managed to do that, then type the following piece of Python command.

import math

The above piece of Python code imports a module which offers functionalities that help to put mathematical theory in practice.

The utility which can be used to find the square root of a number through the Python’s math module is being shown below.


The above is a builtin function. One can easily make use of it by running it through the following syntax.


Once the above piece of Python code gets executed on my Python interactive shell, the following is being displayed as a result.


Final thoughts

One can easily make use of the math.sqrt function to find the square root of any number they desire. There are many other functionalities offered by the Python’s math module which can be used to apply mathematical knowledge, but we are going to explore them in future articles.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Leave a Reply

Your email address will not be published. Required fields are marked *