Computer Science
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)
Python
Python Data Handling
45 Likes
Answer
4.6 7.4
13.799999999999999
21.2
Working
a -= b
⇒ a = a - b
⇒ a = 12 - 7.4
⇒ a = 4.6
a *= 2 + c
⇒ a = 4.6 * (2 + c)
⇒ a = 4.6 * (2 + 1)
⇒ a = 4.6 * 3
⇒ a = 13.799999999999999
b += a * c
⇒ b = b + (a * c)
⇒ b = 7.4 + (13.799999999999999 * 1)
⇒ b = 7.4 + 13.799999999999999
⇒ b = 21.2
Answered By
21 Likes
Related Questions
What will be the output of following Python code?
x, y = 4, 8 z = x/y*y print(z)
Make change in the expression for z in the Python code given below so that the output produced is zero. You cannot change the operators and order of variables. (Hint. Use a function around a sub-expression)
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)
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)