

InterviewSolution
Saved Bookmarks
1. |
Which of the following expressions involves coercion when evaluated in Python?(a) 4.7 – 1.5(b) 7.9 * 6.3(c) 1.7 % 2(d) 3.4 + 4.6 |
Answer» The correct choice is (c) 1.7 % 2 To explain I would say: Coercion is the implicit (automatic) conversion of operands to a common type. Coercion is automatically performed on mixed-type expressions. The expression 1.7 % 2 is evaluated as 1.7 % 2.0 (that is, automatic conversion of int to float). |
|