+ 2

Python

Why in python if i put in 1+3**2=10 i get 10 but in this app the sum was find the missing number so it looked like this 1+ [blank] **2 =16 the answer was 3 but why is there two different answers to the same sum or how to i do this sum in python to get 16 and not 10

14th Jun 2019, 5:51 AM
nick
nick - avatar
2 odpowiedzi
+ 5
Python will always evaluate the same expression the same way. 1+3**2 will always be 10 because exponentiation comes before addition. The only way to get to 16 would be to use parentheses: (1+3)**2 = 4**2 = 16
14th Jun 2019, 6:01 AM
Anna
Anna - avatar
+ 3
thanks
14th Jun 2019, 6:10 AM
nick
nick - avatar