Hello everyone, welcome back to Programming In Python! Here we learn about a Python program that finds the square root of a given number. We find the square root of a number using exponential operations.
Here I calculate the square root by finding the power of the number with 0.5, as you all know that the square root of a number is equal to its power by half. So now I use this way to calculate the result.
One can also find the square root of a number using a built-in function called
sqrt(), Look at my other post here which shows the same.
You can watch this video on YouTube here
Square Root – Code Visualization
To find the square root using exponential operation
- Read the input number for which the square root is to be calculated using
- Use exponential operation ** to that number with 0.5
- The obtained result of the above operation is the required square root.
- Print the result.
num = float(input('Enter a number: ')) sqrt = num ** 0.5 print('The square root of %0.3f is %0.3f' % (num, sqrt))
Master the basics of data analysis in Python. Expand your skillset by learning scientific computing with numpy.
Take the course on Introduction to Python on DataCamp here https://bit.ly/datacamp-intro-to-python