In this article, I will take you through a Python Program to Find the Square Root of a number. But before getting started to find the square root of a number with the Python Programming Language let’s first understand what square root is.
The square root of a number is a value which, multiplied by itself, gives the number. Example: 4 × 4 = 16, so the square root of 16 is 4. One thing to note here is that (−4) × (−4) = 16 too, so −4 is also a square root of 16.
Python Program To Find Square Root
I hope now you know what is a square root of a number. Now let’s see how we can find the square root of a number by using the Python Programming Language.
For the task of finding a square root by using a programming language, we need two variables. One variable for storing the value of that number we want to find the square root. The next variable we need is to store the square root of the number.
If you want to take a user input to store a variable to find the square root of a number, then it is prefered to take the user input as a float. Let’s see how to find the square root using Python:
num = 8 # Or to take the input from the user #num = float(input('Enter a number: ')) num_sqrt = num ** 0.5 print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))
The square root of 8.000 is 2.828
So this is how we can easily find the square root of any number by using the Python Programming Language.
I hope you liked this article on the Python Program to find the Square Root of a number. Feel free to ask your valuable questions in the comments section below.