0
9**(1/2 )>>> 9*1/2=3 which also means 3.0 is it right?
6 Respostas
+ 1
Robin Sampangi
for the answer to be 3.0 you had to put parenteses, like this:
9 ** (1 / 2)
But if there is no parenteses the result will be 4.5.
+ 8
Here is the official blurb on operator precedence.
https://docs.python.org/3/reference/expressions.html#operator-precedence
You can experiment in the Code Playground e.g.
https://code.sololearn.com/czgYkeHQW48X/#py
+ 2
Robin Sampangi
I did not understand your question.
But, if you are asking what is the result of each expression:
9**1/2 = 4.5 # because exponential has greater precedence than division
# so 9 powered by 1 is 9, divided by 2 is 4.5
9 * 1 / 2 = 4.5 # it doesn't matter if you make the multiplication or division first
# you will always end up with 4.5
+ 2
it is exponention and what will be the answer of 9**1/2=? and they showed that the answer is 3.0 which is also called 3
0
so is my code right now ?
0
In the second instance i.e. 9*1/2 You are multiplying 9 by 1 = 9 then dividing by 2.
You must use double asterisk so 9**0.5 would be 3.0
or parenthesis 9**(1/2) = 3.0