CBSE Class 11 Computer Science Question 50 of 80

Conditional and Looping Constructs — Question 20

Back to all questions
20
Question

Question 10(f)

Give the output of the following when num1 = 4, num2 = 3, num3 = 2.

num1 = 2 + 9 * ((3*12)-8)/10
print(num1)
Answer
Output
27.2
Explanation
num1 = 2 + 9 * ((3*12)-8)/10

Let's calculate this step by step, following the precedence of operators in Python:

1. Evaluate the innermost parentheses first:

3 * 12 = 36

2. Replace and continue evaluating inside the parentheses:

((3*12)-8) => (36 - 8) = 28

3. Now, evaluate the multiplication and division:

9 * 28 = 252

4. Continue with dividing by 10:

252 / 10 = 25.2

5. Finally, add 2:

2 + 25.2 = 27.2

The print(num1) statement outputs 27.2