0

dividing numbers

hey, in python shell, i tried to calculate the outcome of this: 6+4/2, and the answer was 8 and 4+6/2 and the answer was 7, now what is the difference between these two?

1st Jul 2020, 3:25 PM
Menno Saedi
Menno Saedi - avatar
2 Respostas
+ 8
You can see this in that way how its calculated, according to the operator precedence. See python docs 3.7, 6.16 'operator precedence': 6 + (4 / 2) -> 6 + 2 -> 8 4 + (6 / 2) -> 4 + 3 -> 7
1st Jul 2020, 3:42 PM
Lothar
Lothar - avatar
+ 2
Menno Saedi Try to lookup on the net for "Python operator precedence" 👍
1st Jul 2020, 3:36 PM
Ipang