- 1
if 1 + 1 * 3 == 6 print ("Yes") else : print ("No")
Im getting invalid output
24 Respuestas
+ 6
Normally, the operator precedence is this: parenthesis, multiplication, division, modulus, addition and subtraction
1 + 1 * 3 = 4
1 + ( 1 * 3 ) = 4
( 1 + 1 ) * 3 = 6
+ 4
That's an invalid syntax. You're missing a colon (:) after 6.
+ 2
like that?
+ 1
I get it now
+ 1
thanks y'all
+ 1
Just check the precedent at first.
Parantheses >exponentiation > multiplication/division > addition/ subtraction.
It's shown the value is not true, so extract to No
0
okay
0
it's still the same
0
if (1+1*3==6)
{
print ("yes") ;
}
else :
{
print ("no") ;
}
0
still error
0
As Dev said, you're missing a colon, it should be like this:
if ( 1 + 1 ) * 3 == 6:
// do stuff
0
like this one??
0
multiplication is executed first .... in order to add 1 to 1 first , and then multiple the result by 3 u must put the addition in ()
0
if( (1+1) * 3 ==6) {
bla bla bla
}
0
Expanding on what noname said.
Here's an article on Operator Precedence:
https://en.wikipedia.org/wiki/Order_of_operations
0
No, multiplication, add, equal
0
Because the first it is multipluing
0
Elisha Miracle
if 1 + 1 * 3 == 6 :
print ("Yes")
else :
print ("No")
0
What is the result of this code?
if 1 + 1 * 3 == 6:
print("Yes")
else:
print("No")
0
What is the result of this code?
if 1 + 1 * 3 == 6:
print("Yes")
else:
print("No")