9**(1/2 )>>> 9*1/2=3 which also means 3.0 is it right? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

9**(1/2 )>>> 9*1/2=3 which also means 3.0 is it right?

11th May 2018, 3:35 PM
Mr.Perfect
Mr.Perfect - avatar
6 Answers
+ 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.
11th May 2018, 4:34 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 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
11th May 2018, 4:39 PM
David Ashton
David Ashton - avatar
+ 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
11th May 2018, 4:14 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 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
11th May 2018, 4:27 PM
Mr.Perfect
Mr.Perfect - avatar
0
so is my code right now ?
11th May 2018, 4:36 PM
Mr.Perfect
Mr.Perfect - avatar
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
24th May 2018, 11:38 PM
Juan Dentone
Juan Dentone - avatar