CBSE Class 11 Computer Science Question 119 of 173

Data Handling — Question 8

Back to all questions
8
Question

Question 5c

What will be output produced by following code? State reason for this output.

a, b, c = 1, 1, 1
d = 0.3
e=a+b+c-d
f=a+b+c == d
print(e)
print(f)

Answer

Output
2.7
False
Explanation

    e = a+b+c-d
⇒ e = 1+1+1-0.3
⇒ e = 3-0.3
⇒ e = 2.7

As 0.3 is float so implicit conversion converts 3 also to float and result of the expression is of float type.

    f = a + b + c == d
⇒ f = 1 + 1 + 1 == 0.3
⇒ f = 3 == 0.3
⇒ f = False

Answer