+ 1
#why is it giving the output as 7? print(3+4%5)
3 Respostas
+ 5
% has the higher order in the calculation, 4 % 5 returns 4
So, 3 + 4 % 5
3 + 4
7
If you wish to make + higher order, embrace the first two numbers with parantheses
Like so,
(3 + 4) % 5
7 % 5
2
+ 2
Because the precedence of Modulous operator in this operation come first then addition operator