sqrt()
` function from the `math
` module :import math
num = float(input("Enter a number: "))
if num >= 0:
result = math.sqrt(num)
print(f"The square root of {num} is {result:.2f}")
else:
print("Invalid input. The number must be non-negative.")
Enter a number: 4
The square root of 4.0 is 2.00
math
` module, which provides various mathematical functions.float()
` function.sqrt()
` function from the `math
` module to calculate its square root and store the result in the `result
` variable. We also use string formatting to display the input number and the calculated square root with 2 decimal places.