- 2
What is the output of a=(((9**2)//10)+1)%2; b=++a;
Give me output of this question.
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 ^^
+ 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
+ 4
run it yourself in code playground (by adding a print statement to output the result stored in a and b) ^^
+ 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
+ 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