Same value within brackets gives a different output compared to within brackets
For the statement print(9 ** 1/2) the output is given as 4.5, but when I print the same statement as print(9 ** (1/2)) I get the output as 3.0, why is that and what is the significance of the brackets in the second statement.
This is because of order or operations (remember PEMDAS?). Items within Parentheses are evaluated first. In the first equation:
9 ** 1 / 2
the Exponent is being evaluated first. 9**1 is still 9, so you do Division next:
9 / 2 = 4.5
For the second equation:
9 ** (1 / 2)
the parentheses are evaluated first. 1 / 2 = 0.5, so you're left with:
9 ** 0.5
An exponent of a half is square rooting, and √9 = 3.