Predict the output of the following.
Attachments:
Answers
Answered by
2
Given : m = 5 and n = 2
To find : m - = n
Answer : Output value of m = 3
To find : n = m + m/n
Answer : Output value of n = 7.5
Explanation :
For the first one,
m - = n is a short way of writing
m = m - n
Hence output value of m = 5 - 2 = 3
For the second one,
n = m + m/n
→ Output of n = 5 + 5/2
Now python converts integers to float here because 5/2 gives float value (= 2.5) (This process is called type casting)
So n = 5.0 + 2.5 = 7.5
Similar questions