0

why in python the result of print(9**(1/2)) is 3.0 and not 3 ?

PYTHON🐍

29th Aug 2022, 4:27 AM
RAHUL KAUSHIK
2 Respostas
0
Because a float division always results in a float, even if it's a whole number (which in this case it is not, even). Any subsequent basic maths operation with a float yields a float again. So... int/int => float int**float => float If you want an int result simply use int( ): print(int(9**(1/2)))
30th Aug 2022, 9:04 PM
Fynn Nix
Fynn Nix - avatar