python square root without math

[Total: 1   Average: 5/5]

Python has an exponentiation operator (**) which can be used to calculate the 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

<script async src=""></script>
<ins class="adsbygoogle" style="display: block; text-align: center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-2624278588064218" data-ad-slot="6795317647"></ins>
     (adsbygoogle = window.adsbygoogle || []).push({});

Leave a Reply

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages