what is the output of this code ? print(int(1+2-3*4/5%6)) explain working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is the output of this code ? print(int(1+2-3*4/5%6)) explain working

Python

2nd Jun 2019, 6:28 AM
PRAVEEN R
PRAVEEN R - avatar
1 Answer
+ 1
Because of operator precedence, you should start with 3 * 4, that's probably where you went wrong. 3 * 4 == 12 12 / 5 == 2.4 2.4 % 6 == 2.4 1 + 2 == 3 3 - 2.4 == 0.6 int() makes floats into integers, so that it ignores decimal points, so 0.6 -> 0
2nd Jun 2019, 6:40 AM
Airree
Airree - avatar