Computer >> Computer tutorials >  >> Programming >> Python

How to perform square root without using math module in Python?


Python has exponentiation operator (**) which can be used to calculate power of a number. x**y returns x raised to y i.e. y times multiplication of x. Since we need to calculate square root, y should be (1/2)

>>> 10**(1/2)
3.1622776601683795
>>> 25**(1/2)
5.0