Computer Science
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)
Python
Python Data Handling
15 Likes
Answer
2.7
False
Working
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
Answered By
9 Likes
Related Questions
What will be output produced by following code? State reason for this output.
a, b, c = 1, 1, 2 d = a + b e = 1.0 f = 1.0 g = 2.0 h = e + f print(c == d) print(c is d) print(g == h) print(g is h)
What will be the output of following Python code?
a = 12 b = 7.4 c = 1 a -= b print(a, b) a *= 2 + c print(a) b += a * c print(b)
What will be the output of following Python code?
x, y = 4, 8 z = x/y*y print(z)
What will be output produced by following code? State reason for this output.
a = 5 - 4 - 3 b = 323 print(a) print(b)