KnowledgeBoat Logo
|

Informatics Practices

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

num1 = 2 + 9 * ((3*12)-8)/10
print(num1)

Python Control Flow

2 Likes

Answer

27.2

Working

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

Answered By

2 Likes


Related Questions