CBSE Class 11 Computer Science Question 114 of 173

Data Handling — Question 3

Back to all questions
3
Question

Question 3

Following Python code has an expression with all integer values. Why is the result in floating point form?

a, b, c = 2, 3, 6
d = a + b * c/b
print(d)

Answer

The output of the above Python code is 8.0. Division operator is present in the expression. The result of Division operator is of float type. Due to implicit conversion, other operand in this expression are also converted to float type and hence the final result is in floating point form.

Answer