codemaniacstudio

Write a Python program to enter any number and calculate its square root.

Write a Python program to enter any number and calculate its square root.

PROGRAM

import math
# Input from the user
num = float(input(“Enter any number: “))
# Check if the number is non-negative
if num >= 0:
sqrt = math.sqrt(num)
print(f”The square root of {num} is: {sqrt}”)
else:
print(“Square root of negative number is not defined in real numbers.”)

OUTPUT

TRY THE ABOVE CODE

Exit mobile version