Python Interview questions - lfa
(Python version 3.9 or later version)
What would be the result of executing the following code?
(lambda x: 3*x // 3 / x%3)(16)
|
1
1.0
8
8.0
|
Explanation
Since all the operators present have the same precedence, calculations will be done left to right
3*x // 3 = x
Then x / x = 1
Then 1 % 3 = 1.0
So, any integer input other than zero will result int he same answer (1.0)
|