+ 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)

25th Apr 2022, 2:50 PM
Chabolu Dharaneesvar
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
25th Apr 2022, 2:55 PM
A͢J
A͢J - avatar
+ 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 ...
25th Apr 2022, 2:58 PM
Lothar
Lothar - avatar
+ 2
x=9 x%=2 X+=3 From Top to bottom 9%2=1 1+3=x =4
7th Nov 2022, 10:12 AM
Ajayi Olumide A
+ 1
That would fail to compile in C. Invalid suffix.
25th Apr 2022, 3:05 PM
William Owens
William Owens - avatar