208k views
5 votes
Write the code in python to input a number and print the square root. Use the absolute value function to make sure that if the user enters a negative number, the program does not crash.

User Havenard
by
4.4k points

2 Answers

3 votes

In python:

print(abs(float(input("Enter a number: ")))**0.5)

User VDVLeon
by
5.2k points
4 votes

Answer:

Code in Python :-

num = float(input("Enter any number : "))

ab = abs(num)

sqrt = float(ab ** 0.5)

print(sqrt)

User Igor Lankin
by
5.0k points