In this program, you’ll learn how to find Square Roots and Display it using Python function.
To properly understand this example to find square roots in Python, you should have the knowledge of following Python programming topics:
- Python Operators
- Python I/O and Import
Program to calculate the square root
#you can change 8 to any number num = 8 # uncomment 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))
Output:
The square root of 8.000 is 2.828
Here in the above Program, we’re storing the number in num and to find the square root we’re using the **
exponent operator.
Note: This program works only for all +ve real numbers. But for -ve or complex numbers.
Related Program:
- Program to Find LCM in Python
- Program to Find HCF or GCD in Python
- Program to find the area of Triangle in Python
- Program to Solve Quadratic Equation in Python
Ask your questions and clarify your/others doubts on Program to find square roots in Python by commenting. Python Documentation