+ 2
What is the output of this code? x = 9 x%= 2 x += 3 print(x)
What is the output of this code? x = 9 x%= 2 x += 3 print(x)
4 ответов
+ 4
Chabolu Dharaneesvar
x%= 2 x += 3
Is right?
x %= 2 means x = x % 2 so x = 9 % 2 = 1
x += 3 means x = x + 3 so 1 + 3 = 4
+ 4
Chabolu Dharaneesvar ,
[Edited]: since no programming language was named, i have assumed it is python code.
this line of the shown code has not a correct syntax:
x%= 2 x += 3
maybe this is meant:
...
x%= 2
x += 3
...
+ 2
x=9
x%=2
X+=3
From Top to bottom
9%2=1
1+3=x
=4
+ 1
That would fail to compile in C.
Invalid suffix.