+ 2
print(6+5-4*3/2%1)
Explain the output of this question
4 Answers
+ 2
P ̲E ̲M ̲D ̲A ̲S ̲
Parenthesis
Exponentiation
Multiplication
Division
Addition
Subtraction
ᎢᕼᏆᔑ Ꮖᔑ Ꭲᕼᗴ ᑭᖇᝪᑕᗴᔑᔑ Ꭹᝪᑌ ᖴᝪᏞᏞᝪᗯ Ꭲᝪ ᔑᝪᏞᐯᗴ Ꮖᑎ ᑭᎩᎢᕼᝪᑎ
+ 11
look:
1. 4*3 = 12
print(6+5-12/2%1)
2. 12 / 2 = 6
print(6+5-6%1)
3. 6 % 1 = 0
print(6+5-0)
4. 6 + 5 = 11
print(11 - 0)
5. 11 - 0 = 11.0
output : 11.0
+ 1
Python uses float division, so the result became a float at step 2 not at step 5:
12 / 2 = 6.0
(Python also has floor division:
12 // 2 = 6
12 // 5 = 2 # decimals ignored
)
Additive operarions(+,-) on integers will result in an int.
4 + 5 = 9
11 - 0 = 11
0
Print(6+5+4*3/2%1)