CBSE Class 11 Informatics Practices
Question 52 of 102
Python Programming Fundamentals — Question 13
Back to all questions4 -10 7
p = 5 % 2The modulo % operator calculates the remainder of the division.
- 5 % 2 = 1
- Thus, p = 1
q = p ** 4The exponent ** operator raises p to the power of 4.
- 1 ** 4 = 1
- Thus, q = 1
r = p // qThe floor division // operator divides and returns the integer quotient of the division.
- 1 // 1 = 1
- Thus, r = 1
p += p + q + rThe += operator adds the value on the right to the variable and assigns it to the variable again.
- Initially, p = 1
- Calculation inside the parentheses: (p + q + r) = 1 + 1 + 1 = 3
- p += 3 means p = p + 3
- So, p = 1 + 3 = 4
r += p + q + rThe += operator adds the value on the right to the variable and assigns it to the variable again.
- Initially, r = 1
- Calculation inside the parentheses: (p + q + r) = 4 + 1 + 1 = 6
- r += 6 means r = r + 6
- So, r = 1 + 6 = 7
q -= p + q * rThe -= operator subtracts the value on the right from the variable and assigns it to the variable again.
- Initially, q = 1
- Calculation inside the parentheses: (p + q * r) = 4 + 1 * 7 = 4 + 7 = 11
- q -= 11 means q = q - 11
- So, q = 1 - 11 = -10
print(p, q, r)The variables now have these final values:
- p = 4
- q = -10
- r = 7
Hence, the output of the program is:
4 -10 7