Python – Calculating Square Root

This is a quick tutorial to find the square root of a number in python. Calculate the square root using the inbuilt math module in a single line of code.

Python comes with a math module. All you need to do is to just import this module and then you can use the object sqrt(). The number for which you want to calculate the square root has to be put inside it as a parameter.

The following example illustrates the use of the object sqrt()of the math module.

import math

integerNumber = 64
decimalNumber = 125.59

print(math.sqrt(integerNumber))
print(math.sqrt(decimalNumber))

Python Square Root Calculation Example

So, this way you can easily calculate the Square Root of any number using the inbuilt math module. I hope you found this guide useful. If so, do share it with others who are willing to learn Python. If you have any questions related to this article, feel free to ask us in the comments section.

Leave a Reply

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