Python Square Root Program – Write a Python Program To find Square root of a number. Three Python programs to find square root of a number using Python.
Code of Python Square Root Programs
Program 1:Use Exponentiation Operator
Exponentiation Operator ** in Python is used to raise the first operand/number to power of second number.
Enter a number: 16
The square root of 16.00 is 4.00
Program 2: Use sqrt() function of Math Module
The sqrt() function is a predefined method of Math module. This function will find the square root of a given number in Python.
Note: import the math module before using sqrt() function.
Enter a number: 81
The square root of 81.00 is 9.00
Program 3: Use builtin pow() function
pow() function will take two arguments, first is number and second is power of that number. For example pow(8,2) will return 64. It means that pow(number,power) function will calculate the number raised to the given power.
Enter a number:10
The square root of 10 is 3.16
You may also like the following programs:
Similar to Python Square root Program Concept
74 total views, 1 views today