Understand the number tower.
Rule 1 For two operands of the same type, the result will be of this type.
eg. int / int = int
temp**(1/8) does not give the 8th root of temp, because:
>>>1/8 0
Rule 2 If the operands are mixed, one of them will loop into the number tower: integer → rational → float → complex.
eg. float / int = float
>>>1./8
Note There may be times when these rules do not apply to true division / and division of sex //, but I do not understand them completely. See Link.
"They did research that you know, they work 60% of the time ... every time." - Brian Fantana
Trap . In the OPs question, the expression temp**(1/8) made of mixed operands (temp is a float), so why not a (1/8) float?
The operands are evaluated in accordance with BODMAS / BIDMAS, therefore, first evaluated (1/8) , the resulting expression becomes temp**0 , and at that moment 0 forced to float.
Any positive int or float for a power of 0.0 is 1.0 .
source share