Computer Science
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)
Python Data Handling
34 Likes
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.
Answered By
19 Likes
Related Questions
What will be the output, if input for both the statements is 5 + 4/2.
6 == input ("Value 1:")
6 == int(input ("value 2:"))What is the result produced by (i) bool (0) (ii) bool (str(0))? Justify the outcome.
What will following code print?
a = 3 b = 3.0 print (a == b) print (a is b)
What will following code print?
a = va = 3 b = va = 3 print (a, b)