CBSE Class 11 Computer Science
Question 47 of 98
Python Programming Fundamentals — Question 9
Back to all questions66.66666666666667 126.66666666666667
p *= q / 3The *= operator multiplies p by the value on the right and assigns it to p again.
- First, compute the division: q / 3 = 20 / 3 ≈ 6.6667
- p *= 6.6667 means p = p * 6.6667
- So, p = 10 * 6.6667 = 66.6667
q += p + q * 2The += operator adds the value on the right to q and assigns it to q again.
- First, compute q * 2 = 20 * 2 = 40
- Then add values: p + q * 2 = 66.6667 + 40
- Finally, add it to
q: q += 106.6667 means q = q + 106.6667 - So, q = 20 + 106.6667 = 126.6667
print(p, q)The variables now have these final values:
- p = 66.6667
- q = 126.6667
The precision difference is due to floating-point arithmetic. For simplicity of explanation we have taken lesser precision values.