- 2

What is the output of a=(((9**2)//10)+1)%2; b=++a;

Give me output of this question.

10th Jun 2021, 1:15 AM
Praveen Saini
Praveen Saini - avatar
6 odpowiedzi
+ 3
Pŕávèéņ Sàini the second part of your expression is not valid in Python, as Python doesn't have increment unary operators... [ edit ] "not valid" in the sense that it does not produce an increment ^^
10th Jun 2021, 2:28 AM
visph
visph - avatar
+ 5
GAYATHRI KOLLURI 81 // 10 == 8, in python, not 1 ^^ a = ( ( (9**2)//10 ) + 1 )%2; a = ( ( 81//10 ) + 1 ) % 2; a = ( 8 + 1 ) % 2; a = 9 % 2; a = 1; b = ++a; in python NO incrementation operator: b = + ( +a ) b = + ( +1 ) b = + 1 b = 1 a = 1 , b = 1
11th Jun 2021, 10:02 AM
visph
visph - avatar
+ 4
run it yourself in code playground (by adding a print statement to output the result stored in a and b) ^^
10th Jun 2021, 1:25 AM
visph
visph - avatar
+ 2
Understand the operators precedence and associativity will help you to easily derive the output of any question only by continuously solving problems https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/precedence-associativity
10th Jun 2021, 2:22 AM
Nanda Balakrishnan
+ 2
Nanda Balakrishnan there's no question about operator precedence here, as the expression has parenthesis wich set explicit precedence ^^ anyway, your link is about operator precedence in C, while OP has tagged Python in the question ;P
10th Jun 2021, 2:25 AM
visph
visph - avatar