In this post, we will learn how to find square root in Python with detailed explanation and Example.

Finding the square root is a very simple task. There are two basic approaches in Python to find the square root of the number.

  1. Without using a math module
  2. Using math module

    We will explore both ways one by one. So let’s start learning…

    Without Using a Math Module

    There is ** Arithmetic operator in Python we will achieve our goal of finding out the square root of the number using this operator. let’s see how.

    num = float(input('Enter a number: '))
    sqrt_root = num**0.5
    
    print(f"Square root of {num} is : {sqrt_root}")

    Output:

    Enter a number: 25
    Square root of 25.0 is : 5.0

    Using a Math Module

    The math module provides a built-in function called math.sqrt(). This function returns the square root of the number. let’s see how.

    import math
    
    num = float(input('Enter a number: '))
    print(f"Square root of {num} is : {math.sqrt(num)}")

    Output:

    Enter a number: 49
    Square root of 49.0 is : 7.0

    These are two basic ways you can follow to find out the square root of the number in Python. I hope this post adds some value to your knowledge thank you for reading this article see you in the next one.

    Author

    Hi, I'm Yagyavendra Tiwari, a computer engineer with a strong passion for programming. I'm excited to share my programming knowledge with everyone here and help educate others in this field.

    Write A Comment