I made this cube root code,but it didn't work for negative numbers. It always print "No cube roots" even though types of negative numbers are either float or int.
Here's my code:
Here's my code:
1 2 3 4 5 6 7 8 9 10 |
a = input () if type (a) = = float or type (a) = = int : if a > 0 or a = = 0 : print ( round ( float (a * * ( 1 / 3 )), 15 )) else : a = abs (a) b = round ( float (a * * ( 1 / 3 )), 15 ) print (b * - 1 ) else : print ( "No cube roots" ) |