What will be the value of X from the following code snippet?
AB= 10.3
X=Alf (A/B==3) else B
print(x)
(A) 3
(8) 10
(C) True (D) Falsa
Answers
Answered by
15
Answer:
(A) 3
Explanation:
In line 1,
value 10 is stored in A, and value 3 is stored in B.
In line 2,
it says, if A/B==3, value of A is stored in X, else, value of B is stored in X.
The main thing to notice over here is,
A/B is a normal division which gives the value in decimals.
So, A/B=10/3 gives 3.33333... which is not equal to 3.
As A/B is not equal to 3,
The value of B is stored in X; i.e., X=3
Note: X would have been stored with the value of A, if we use floor division (A//B), which rounds up the value of decimal too the nearest lowest integer.
Attachments:
Similar questions