- 2

Why 9**1/2 results a float number while 9**2 results an integer? In python

21st May 2018, 3:53 PM
Rballiwal
4 Answers
+ 3
9**2=18 thats an integer. but in your 2nd: you think the cpu is doing: 9**(1/2) when its actually doing: (9**1)/2 so output is 4.5
21st May 2018, 4:07 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 2
also 9**(1/2) is 3.0 using the exponential operator on fractions or negative numbers results in a float
21st May 2018, 4:11 PM
᠌᠌Code X
᠌᠌Code X - avatar
0
I believe Python sees (1/2) as 0.5 which is a float.
24th May 2018, 11:44 PM
Juan Dentone
Juan Dentone - avatar
- 1
Thanks brother
21st May 2018, 4:11 PM
Rballiwal