+ 1
Why is the output of this code "no"?
if 1+1*3==6: print("yes") else: print("no")
4 Answers
+ 6
All of the multiplication occurs first,so you end up with 1*3=3 then it goes on to the next mathematical part, 1+3=4. So when the computer looks at it it sees "if 4 is equal to 6 then true, otherwise false." I hope that helps.
+ 3
1+1*3 - Python's order of operations is the same as that of normal mathematics: parentheses first, then exponentiation, then multiplication/division, and then addition/subtraction. Here your answer. :)
+ 1
basic maths teach you this: Everything withing paranthesis first, then division and multiplication, then addition and subtraction. The computer also follows these rules. 1+1*3= 1+(1*3) = 1+3 = 4. 4 != 6.
+ 1
Python follows the order of operations same as algebra.