+ 1

#why is it giving the output as 7? print(3+4%5)

19th Oct 2021, 4:32 AM
Yukeshan Yoganathan
Yukeshan Yoganathan - avatar
2 Answers
+ 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
19th Oct 2021, 4:34 AM
Tim
Tim - avatar
+ 2
Because the precedence of Modulous operator in this operation come first then addition operator
19th Oct 2021, 12:58 PM
Abhishek Kumar
Abhishek Kumar - avatar