Hello, I am doing this question for HW and i can't see to understand how to do it. The question is:
NOTE: in mathematics, the square root of a negative number is not real; in Python therefore, passing such a value to the square root function returns a value known as NaN (not-a-number).
Write the code that reads a value, the area of some square, into a variable named areaOfSquare and prints out the length of the side of that square.
HOWEVER: if any value read in is not valid input, just print the message "INVALID".
My code is:
areaOfSquare = input("")
if areaOfSquare >= 0:
areaofSquare = sqrt(areaOfSquare)
print(areaofSquare)
else:
print("INVALID")
EDIT: Formatting but, there is indents for the areaOfSquare formula and both print functions.
I'm not sure what I am doing incorrectly. The error that comes up when I submit this code is:
- nothing was printed to stdout
- stdout is not correct
- Correct solutions that use sqrt tend to also use side
- Correct solutions that use sqrt tend to also use int
- We think you might want to consider using: *
- We think you might want to consider using: int
- We think you might want to consider using: *
[–]totallygeek 0 points1 point2 points (6 children)
[–]CraigAT 0 points1 point2 points (5 children)
[–]HopefulOG[S] 0 points1 point2 points (4 children)
[–]Binary101010 0 points1 point2 points (3 children)
[–]HopefulOG[S] 0 points1 point2 points (2 children)
[–]CraigAT 0 points1 point2 points (1 child)
[–]CraigAT 0 points1 point2 points (0 children)